[Windows] Help creating an .bat (batch) script for renaming a couple of files
#1
I`m trying to create a small batch script to rename the backdrops.jpg saved by Media Center Master as local metadata to an extrathumbs folder, with each jpg renamed to thumb1,thumb2 etc. I got most of it working with one small issue. When remaming the "backdrop.jpg" it outputs "thumbrop.jpg" instead of "thumb.jpg". I did a little research and it seems the "ren" (rename) command bat only renames as much caracters as the new name, and continues to put the rest of the left letters in the new name ouput.

Any ideeas on how to directly rename "backdrop.jpg" to thumb.jpg or to re-rename the resulting "thumbrop.jpg" to "thumb.jpg" ? Here is the script code, btw

Code:
--- begin script ---
m:
cd D:\Movies
for /f "tokens=1*" %%A in ('dir /b *') do call:ENTER %%A %%B
goto:EOF

:ENTER
set folder=%*
@echo Working in folder %folder%

if not exist "D:\Movies\%folder%\extrathumbs" mkdir "D:\Movies\%folder%\extrathumbs"
@echo ...moving backdrops*

move "D:\Movies\%folder%\backdrop*.jpg" "D:\Movies\%folder%\extrathumbs\
cd D:\Movies\%folder%\extrathumbs\
ren "backdrop*.jpg" "thumb*.jpg"


goto:EOF
--- end script ---
Reply
#2
change
Code:
ren "backdrop*.jpg" "thumb*.jpg"
to
Code:
ren "backdrop*.jpg" "thumb.jpg"

but that won't add the 1, 2, 3... damn.....

can you make backdrop*.jpg into something like backdrop<some sort of variable name> and then rename to thumb<some sort of variable name>.jpg ??
Openelec on ASRock ION 330 / Kodi on Win 7 PC
Reply
#3
Thanks rocketpants, but i found a simpler solution. Just added a rename command for each backdrop.jpg like this

Code:
ren "backdrop.jpg" "thumb1.jpg"
ren "backdrop1.jpg" "thumb2.jpg"
ren "backdrop2.jpg" "thumb3.jpg"
ren "backdrop3.jpg" "thumb4.jpg"

Since i only need 4 thumbs and i can set MCM to only download 4 backdrops, it works perfectly Big Grin
Reply

Logout Mark Read Team Forum Stats Members Help
[Windows] Help creating an .bat (batch) script for renaming a couple of files0