Reputation: 1
Okay, I have a lot of subfolders. Each subfolder contains some files. In each subfolder I want to add som text in the end of one file with the extension "tbn". The file name is not the same in each folder. Then I also want to change/rename the extension to jpg. See my example below
rename "myfile.tbn" to "myfile-poster.jpg"
I would like to do this from the command promt or from a batch file.
Have googled some of this. I would say my problem is to add the text in the end of the file "-poster" when the orginal filename varies.
Upvotes: -1
Views: 131
Reputation: 56180
You can find a file with an unknown name with a plain for
loop (see for /?
for details).
/R
makes it recursive (searching through subfolders too)
the %%~n
modifier returns the base filename only (no extension)
for /R %%A in (*.tbn) do ECHO ren "%%A" "%%~nA-poster.jpg"
Remove the ECHO
after verifying it does what you want to actually enable the ren
command.
Upvotes: 0