[Solved] Read txt files through batch

Score
0
Vote Up
February 5, 2012 at 07:31:18 Pacific
Specs: Windows XP

Im a newbie pls suggest :- Is it possible to read txt files with the help of batch? there are 100 of txt files in a folder and in certain txt files a word for eg :-computing.net is written.... is ther any idea or batch to delete every txt files in the folder apart from the files which is containing the string computing.net...

Jump to Best Answer ↓   Report •


#1
Vote Down
Score
0
Vote Up
February 5, 2012 at 07:47:36 Pacific

Best Answer

A batch script can read and even parse text files in many ways, now according to what you want to achieve

@echo off & setlocal
cd Your_Folder
for %%j in (*.txt) do type "%%j" | find /I "computing.net" > nul || del "%%j"


Reply ↓  Report •

#2
Vote Down
Score
0
Vote Up
February 6, 2012 at 04:01:55 Pacific

Thank u dude its works ...how to do the same thing in a directory? is it possible?>

Reply ↓  Report •

#3
Vote Down
Score
0
Vote Up
February 6, 2012 at 06:42:11 Pacific



"How to do the same thing in a directory? Is it possible?"

What do you want to mean/achieve? The posted script does what you requested for all files stored in a directory and strings/words are stored in files not in directories.

Reply ↓  Report •

#4
Vote Down
Score
0
Vote Up
February 7, 2012 at 06:46:49 Pacific

The script checks for the word"computing.net" in the files which is kept in the current folder but is it possible to do check in the directory?

Reply ↓  Report •

Reply to Message Icon Start New Discussion
Related Posts

« [Solved] How Do I Check If a Progr... How Do I Delete Lines Fro... »