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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to 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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 4, 2009 at 07:31:51 Pacific
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


0

Response Number 2
Name: daphnez
Date: May 4, 2009 at 10:32:15 Pacific
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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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


Sponsored links

Ads by Google


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