1.

Solve : Need advice in appending current date to the file name?

Answer»

Hello All,

I am trying to append the current date to the end of the file name and I am using bat file script to do it. For example, I have the file 1.txt and when I use the script, the file name should be renamed as 1_29_09_2011.txt.

The script works good in Windows 7 and Windows 2003 Enterprise x64 Edition SP2.

However, for Windows 2003 Standard Edition SP2, the output I am receiving is 1_09-2011-.txt

The below are the contents of the bat file script:

for %%a in ("1.txt") do (
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "%%a" "%%~Na_%%e-%%f-%%g%%~Xa"
)

The OS version where I have issue is: Windows 2003 Standard Edition SP2.

Please HELP me in this regard. THANKS in advance.
On the system that is acting up, have you VERIFIED the output structure of %date% such as running echo. %date% from command shell to make sure its the correct structure format, same order as the other SYSTEMS that work correctly. To me it looks like your system that is acting up for this batch is not the same %date% output structure?

Your example of what you should get shows DDMMYYYY and your undesired output is showing MMYYYY missing the DD ( Day value)



Discussion

No Comment Found