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).