General discussion

Locked

COPY Command in DOS

By naseemi ·
Hi,

I wish to copy a file (C:\DIRECTORY1\FILE1.TXT) to another subdirectory but with the current date appended to the filename (C:\DIRECTORY2\FILE1_20APR2005.TXT)

Is there a way to do this type of file copy using the COPY command (or any other) in DOS? I want to write this into a batch file as a form of backup process.

Please email me at : naseemi@webmail.co.za

Many thanks in advance

Naseem

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by pryzhkov In reply to COPY Command in DOS

If You set in Your batch file something like:

SET CC=%DATE:~4,2%-%DATE:~7,2%-%DATE:~10,4%

it will give You the value of current date,
i. e. 04-20-2005. So You can use it to change the name of Your file...

Collapse -

by deveshpradhan In reply to COPY Command in DOS

Try this
SET CC=%DATE:~0,2%%DATE:~3,2%%DATE:~6,4%
COPY C:\DIRECTORY1\FILE1.TXT C:\DIRECTORY1\FILE1.TXT_%CC%

This will create a file named FILE1.TXT_22042005
in the C:\DIRECTORY1 folder.

Hope this helps you.

Good Luck

Collapse -

by naseemi In reply to COPY Command in DOS

Thanks guys!
All sorted out!
Much appreciated

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums