Renumber files in all sub-folders

December 13, 2010 at 10:38:46
Specs: Windows XP
Hi,

I have this batch file which renumbers all the files in a particular directory i.e. Test

for %%i in (C:\Test\*.txt) do (
call ren %%i rep%%n%%.tx_
set /a n=n+1)

ren *.tx_ *.txt

Its working fine however I have 10 sub-folders in Test (Main folder), how can I goto each sub-folder and renumber files?

V


See More: Renumber files in all sub-folders

Report •


#1
December 13, 2010 at 11:14:25
If it works, beats me how.

Your call line gives me:

The syntax of the command is incorrect.


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
December 13, 2010 at 11:18:07
I missed to paste 1 line where I'm setting n=1. Here is the complete code

set n=1

for /f %%j in (C:/Test/*.txt) do (
call ren %%j rep%%n%%.tx_
set /a n=n+1)

ren *.tx_ *.txt

This works for me


Report •

#3
December 13, 2010 at 11:23:47
I did it myself..never mind


for /d %%i in (C:\Test\*) do (
pushd %%i

set n=1

for %%j in (%%i\*.txt) do (
call ren %%j rep%%n%%.tx_
set /a n=n+1)

ren *.tx_ *.txt
)


Report •

Related Solutions


Ask Question