Friday, October 14, 2011

Search for a word in a folder having hundreds of files

Today as part of migration I was asked to search for the occurrence of the word INDIA in a folder named GROUP. I have to replace the name INDIA with New_India in each and every file and the folder has almost more than 300 files :O

Then I found a useful command in Google ‘findstr’. With this DOS command we can search for a particular word in entire directory. Using this command we can search in different ways based on our requirement.

For my example it will be:

Open command prompt.
findstr /s /i /m "\<INDIA\>" *.*

Here *.* indicates to search in all kinds of file formats and names.
S – searches for matching files in current folder and all its sub folders.
I – irrespective of case sensitivity
M – prints file name if it finds a match.
\< \> for beginning of the word and ending of the word respectively.

No comments:

Post a Comment