windows 7 - Intuitive file sorting in batch scripts? -
so in windows explorer, have these files sorted this:
i have script remove brackets , 1 zero, , in case trailing number greater or equal 10, remove 2 zeroes:
cd c:\folder setlocal enabledelayedexpansion set /a count=0 %%a in (*.jpg) ( set /a count+=1 echo !count! set f=%%a if !count! gtr 9 ( set f=!f:^00 (=! ) else ( set f=!f:^0 (=! ) set f=!f:^)=! ren "%%a" "!f!" ) pause
however, once run code, result:
so batch file isn't going through files "intuitively" windows explorer shows them. there way change this? or there better way rename these files altogether?
this uses different approach:
@echo off cd c:\folder setlocal enabledelayedexpansion set /a count=0, remove=2 /f "delims=(" %%a in ('dir /b *.jpg') ( set /a count+=1 echo !count! set "f=%%a" if !count! equ 10 set "remove=3" /f %%r in ("!remove!") set "f=!f:~0,-%%r!" ren "%%a" "!f!!count!.jpg" ) pause
Comments
Post a Comment