For Do rename loop

210 pts.
Tags:
Batch file
Batch files
Command line
LOOP statement
Would anyone know of a createive way to change the following to represent a "do ren" loop and cleanup some of the un-needed syntax?

for /f "tokens=1-9 delims=/ " %%d in ("%date%") do ren "A B C *.xlsx" "A B C %%e %%f %%g.xlsx"

for /f "tokens=1-9 delims=/ " %%d in ("%date%") do ren "D E F *.xlsx" "D E F %%e %%f %%g.xlsx"

for /f "tokens=1-9 delims=/ " %%d in ("%date%") do ren "G H I *.xlsx" "G H I %%e %%f %%g.xlsx"

Thank you.

ASKED: October 7, 2011  1:54 PM
UPDATED: March 31, 2012  12:28 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

<pre>@echo off
REM Other stuff here

REM Move all the renames into one called section and reduce to single for statement
REM Reduce to just the tokens required for grabbing the date
for /f “tokens=2-4 delims=/ ” %%a in (“%date%”) do CALL :RenScript %%a %%b %%c

REM More stuff here
goto :DONE

:RenScript
ren “A B C *.xlsx” “A B C %1 %2 %3.xlsx”
ren “D E F *.xlsx” “D E F %1 %2 %3.xlsx”
ren “G H I *.xlsx” “G H I %1 %2 %3.xlsx”
GOTO :EOF

:DONE
REM Script cleanup here
</pre>

What i get for being click happy ;-)

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following