Computing.Net > Forums > Programming > Batch file for renaming directory

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Batch file for renaming directory

Reply to Message Icon

Name: daphnez
Date: May 4, 2009 at 04:18:29 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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




Response Number 1
Name: Mechanix2Go
Date: May 4, 2009 at 07:31:51 Pacific
+1
Reply:

@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



Response Number 2
Name: daphnez
Date: May 4, 2009 at 10:32:15 Pacific
+1
Reply:

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



Reply to Message Icon

Related Posts

See More


user licence of software ias log files



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Google Ads



Results for: Batch file for renaming directory

Batch file for renaming files www.computing.net/answers/programming/batch-file-for-renaming-files/15423.html

Batch file for renaming folders www.computing.net/answers/programming/batch-file-for-renaming-folders/15430.html

batch for renaming www.computing.net/answers/programming/batch-for-renaming/14941.html