View Single Post
Old 05-25-2015, 03:05 AM   #4
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
Thanks! I had to put an additional double quotes pair because the file names contain spaces, but after that it worked fine:
FOR %%f IN ("*.doc") DO (
findstr /m /c:"rtf1" "%%f" && REN "%%f" "%%~nf.rtf"
)

I think a bulk rename utiliy with file search capabilities would be good for this task too, especially when working in multiple folders (but Flexible Renamer doesn't filter files by file content). Or I suppose the FOR loop could be modified to search recursively with a modified syntax (the /R parameter?). I know some ms-dos, but not good enough for this.

I tried to modify the batch file to work recursively for all doc files:
Code:
D:
CD "D:\testRTF"
FOR /R "D:\testRTF" %%f IN ("*.doc") DO  (
findstr /m /c:"rtf1" "%%f" && REN "%%f" "%%~nf.rtf"
)
PAUSE
REM REN "%%f" "%%~df%%~pf%%~nf.rtf"
Initially I used a wrong syntax for REN: REN "%%f" "%%~df%%~pf%%~nf.rtf" and I was getting an error (becuase the new file name musn't include the parth).

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