Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batch Rename with Incremental numbe
Name: redwax Date: December 13, 2007 at 12:01:46 Pacific OS: xp CPU/Ram: ath64,4000,1024 Product: na
Comment:
Hi, I have a batch files which converts some images using image magick. It does a small amount of renaming already, however, It would be really useful if it could append an incrementing number. This is what I have so far:
:RUN_PRODUCT mkdir products cd products mkdir small mkdir large cd ../ for %%f IN (*.jpg) do convert %%f -strip -resize 150x150 -quality 70 products/small/%%f for %%f IN (*.jpg) do convert %%f -strip -resize 600x600 -quality 95 products/large/%%~Nf_LRG.jpg goto start
I would ideally like to insert the 2 digit incremental prior to the _LRG part of the name, so have blah_01_LRG.jpg, blah_02_LRG.jpg etc.
Name: IVO Date: December 13, 2007 at 12:52:18 Pacific
Reply:
Start your batch by coding
@Echo Off SetLocal EnableDelayedExpansion
then
Set index=0 for %%f IN (*.jpg) do ( Set /A index+=1 If !index! lss 10 Set index=0!index! Set index=_!index! convert %%f -strip -resize 600x600 -quality 95 products/large/%%~Nf!index!_LRG.jpg Set index=!index:_0=! Set index=!index:_=! )
0
Response Number 2
Name: redwax Date: December 13, 2007 at 13:03:51 Pacific
Reply:
Amazing, thank you so much, that did just the job!
0
Response Number 3
Name: Blasterman Date: January 1, 2008 at 11:29:52 Pacific
Reply:
Note that the solution won't work in Windows 9x,ME, or DOS.
All the OSes I use: Windows XP, Windows 98, MS-DOS 6.22, OpenBSD 2.6, DLX Linux. I have 4 computers, one of which is emulated.
0
Response Number 4
Name: User123456789 Date: January 3, 2008 at 04:24:17 Pacific
Summary: Okay, I'm cross-training again so I'm new to batch programming. This one is probably pretty simple but I haven't been able to find out quite how to do it. I need to take a bunch of files and rename th...
Summary: The problem is in the batch renaming. I have a folder, full of files, which names have to be processed in such a way, that, for example, filename00.txt becomes filename.cd1.txt, etc. I`ve written a ba...
Summary: I am attempting to perform a batch rename on several files with the same extention in a drive. I am looking to be able to rename the following 600895789473_01_Track01.wma to 600895789473_01_01_128....