DOS; rename multiple files, append text w bat

October 15, 2010 at 07:18:12
Specs: Windows XP
Ok, here is my task. I have several thumbs created and need to add the resolution to the end.

eg

abc12345_001.jpg
abc12345_002.jpg
abc12345_003.jpg
abc12345_004.jpg
abc12345_005.jpg
etc...

rename to:

abc12345_001_640x360.jpg
abc12345_002_640x360.jpg
abc12345_003_640x360.jpg
abc12345_004_640x360.jpg
abc12345_005_640x360.jpg

my poor attempt:
echo
c:
copy C:\data\test\*jpg C:\data\test\resized_thumbs
cd \data\test\resized_thumbs
ren *.jpg *_640x360.jpg
rem del C:\data\test\*jpg C:\data\test\*jpg
pause

Is the underscore throwing me off?

Thanks in advance!!
TC


See More: DOS; rename multiple files, append text w bat

Report •

#1
October 15, 2010 at 12:24:06
for /f "delims=" %%a in ('dir /b /a-d *.jpg') do ren "%%a" "%%~Na_640x360%%~Xa"

How To Ask Questions The Smart Way


Report •

#2
October 15, 2010 at 12:31:05
Razor2.3: Wow! Worked absolutely perfectly!

Report •

#3
October 15, 2010 at 21:13:24
download gawk for windows then use this one liner

C:\test>dir /B abc* | gawk "{o=$0;sub(/.jpg/,\"_640x360.jpg\",o); cmd=\"ren \042\"$0\"\042 \042\"o\"\042\"; system(cmd)}
"

GNU win32 packages | Gawk


Report •

Related Solutions

#4
March 1, 2011 at 02:42:27
Oh, man! With minor changes it worked great to batch convert my PCDs to JPGs!! Cool man!! Thank you so much!!!

Report •

Ask Question