View Single Post
Old 05-25-2015, 08:12 AM   #5
rebl
r.eads e.njoys b.ooks lol
rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.rebl ought to be getting tired of karma fortunes by now.
 
rebl's Avatar
 
Posts: 76
Karma: 580748
Join Date: Mar 2010
Location: It's time to get this Book a Rest
Device: Kindle 4 NT
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

Last edited by rebl; 05-25-2015 at 08:21 AM.
rebl is offline   Reply With Quote