Increasing Number Batch Rename

November 25, 2009 at 13:45:01
Specs: Windows XP
I have a 431 .tif files with matching .tfw files that I need to rename while increasing the image number by 1. Files are named
redrock-001.tif and redrock-001.tfw
to
redrock-431.tif and redrock-431.tfw.
Starting at image 076, I need to shift all the image numbers +1. Ex: redrock-077.tif
becomes redrock-078.tif etc. for the rest of the files. I can move the first 76 out of the folder before batching if that would simplify things. Any help would be greatly appreciated!
Thanks

See More: Increasing Number Batch Rename

Report •


#1
November 25, 2009 at 14:51:12
@echo off & setLocal EnableDELAYedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d/o-n redrock*.tif') do (
  set S=%%a
  set S=!S:~8,3!
  call :sub1
ren %%a redrock-!S!.tif
)

goto :eof

:sub1

  :loop
    if !S:~0^,1! equ 0 (
      set S=!S:~1!
      goto :loop
    )

set /a S+=1
if !S! lss 100 set S=0!S!

goto :eof


=====================================
Helping others achieve escape felicity

M2


Report •

#2
November 25, 2009 at 15:12:33
Thanks a bunch Mechanix2Go !!!
Works great.
Very much appreciated.
Brad



Report •

Related Solutions


Ask Question