Batch traverse subolders and rename files -


i traverse folder , it's subfolders, keep counter variable of current file , rename $counter$existingfilename.
e.g.

$count = 1;   foreach $file in $folder   {     $file.name = $count + $file.name;     $count++;   } 

the person can answer hero! :)
btw using windows 7.

all right, while pondering on questions in comment post (or maybe still making way site read them), here's trial shot:

@echo off set "rootdir=%~1" if "%rootdir%"=="" set rootdir=. set cnt=0 /r "%rootdir%" %%f in (*) (   set /a cnt+=1   setlocal enabledelayedexpansion   rename "%%f" "!cnt!%%~nxf"   endlocal ) 

this rename files prepending names numbers, this:

1file.txt 2program.exe ... 

if like, can have way:

00001file.txt 00002program.exe 

for you'll need make 2 changes above script (highlighted in bold):

@echo off set "rootdir=%~1" if "%rootdir%"=="" set rootdir=. set cnt=10000 /r "%rootdir%" %%f in (*) (   set /a cnt+=1   setlocal enabledelayedexpansion   rename "%%f" "!cnt:~1!%%~nxf"   endlocal ) 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -