I am trying to optimize the above batch file for working on a large number of files.
I was wondering if the findstr in the sintax above looks for the string "rtf1" throughout the whole file - that could take quite a long time. If the string is not found in the first line, the file should be skipped.
I found that the /B option is for matching the string only at the beginning of a line, but I couldn't find any option for matching the beginning of the file.
Also, I'm wondering if i could use "{\rtf1" for the string (should I escape the "\")?
It seems "{\rtf" works, I'm not sure if with \B is really faster but here is what I'm going to test:
Code:
PAUSE
D:
CD "D:\FolderName"
FOR /R "D:\FolderName" %%f IN ("*.doc") DO (
findstr /B /M /C:"{\rtf" "%%f" && REN "%%f" "%%~nf.rtf"
)
PAUSE