Batch file for renaming directory

May 4, 2009 at 04:18:29
Specs: Windows XP
Heloo

I have several directory:

12042007
13042007
05062008
06072008
01012009

and i want to move the year to be in front of the directory name....

20071204
20071304
20080506
20080607
20090101

i am trying to use For /f "tokens=2,3 delims=2007" %%i ...

but it seem not working...

any advice??

thanks


See More: Batch file for renaming directory

Report •


#1
May 4, 2009 at 07:31:51
@echo off & setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%a in ('dir/b/ad') do (
set old=%%a
set Y=!old:~4,4!
set DM=!old:~0,4!
echo ren %%a !Y!!DM!
)


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
May 4, 2009 at 10:32:15
wow...thanks a bunch...
it worked...

btw i have a question...

where can i learn about this parsing...
some good link perhaps...

and why we need "setLocal EnableDelayedExpansion"

thanks again


Report •

Related Solutions


Ask Question