1.

Solve : Renaming a file to today's date?

Answer»

I am trying to rename a file to include the current date.  So I want to rename the file myfile.txt to myfile08262004.txt.  I am writing this program that will create this file every month and put it out in a DIRECTORY.  Once it is there I am using DOS to rename the file to the current date and then FTP to a server. I can't find a way to rename my file to the current system date..can anyone help??

Thanks in advance!check the thread "whos an expert with dos?" ... same issueHave a look at this
rem *** Moves JFMOVE to E:\JFBACKUP\Raw_Data and renames it as the System Date and Time ***
----------------------------------------------------------------------
Move E:\JFBACKUP\JFMOVE "E:\JFBACKUP\Raw_Data\%date:~4,2%%date:~7,2%%date:~-2,2%%time:~0,2%%time:~3,2%"
------------------------------------------------------------------------
Have study of this lines I used in my Batch. That's the working format for me.

Cheers!
Willzuse the copy command (many parts to this powerful command)

copy oldfile +,,


thats it!  you may be prompted to overwrite the oldfile.
say yes.  if your anxious about it copy it to a DIFFERENT directory
and try it thereWell I live the UK and all my system dates are in UK format, so for those of you (like me) who NEED it simple:

Code: [Select]MOVE "c:\myfile.txt" "c:\myfile_%date:~0,2%-%date:~3,2%-%date:~6,4%_%time:~0,2%-%time:~3,2%-%time:~6,2%-%time:~9,2%.txt"

The line above will RENAME "c:\myfile.txt" to "myfile_24-11-2004_12-48-04-39.txt"

HOPE this helps SOMEONE else.

PS -  can't find the old thread, mentioned above.




Discussion

No Comment Found