Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Copy a file and appending a timestamp to its name...

Posted on 2006-05-23
3
Medium Priority
?
618 Views
Last Modified: 2007-11-27
I need to know if I can append the timestamp to the end of the filename using the command line in Windows XP. I have a couple of jobs in Unix, where I can do this, and I need help doing this in Windows.

Example:

I have a file:                CCAOPCL.txt (it always has this name)

I want to copy that file to:
                                  CCAOPCL_20060523.txt

0
Comment
Question by:SharonBernal
3 Comments
 
LVL 5

Expert Comment

by:Dragon_Krome
ID: 16747269
I don't think you can do that by using only the commandline. You could try to create a script though, and run it via WSH

Here's an example script which gets the date/time of a file, among others.
http://www.winscripter.com/WSH/FileIO/68.aspx

For copying the file, you can do something like fso.CopyFile(src,dest,true);  (see this other script which performs copying: http://www.winscripter.com/WSH/FileIO/290.aspx)

0
 
LVL 59

Accepted Solution

by:
LeeTutor earned 1000 total points
ID: 16747350
Here's a web page that describes a batch file to do very close to what you want:

http://www.windowsitpro.com/Article/ArticleID/13575/13575.html

You would need to change the "rename" command to "copy" in the batch file, and if you're not interested in the time being appended to the file name, but only the date, then just leave out references to that.
0
 
LVL 14

Expert Comment

by:FriarTuk
ID: 16749422
here's my own personal batch,

::: will set zdate to YYYYMMDD
SET zdate=%date:~-4%%date:~4,2%%date:~7,2%
::: will add date to end of file name
COPY c:\CCAOPCL.txt c:\CCAOPCL_%zdate%.txt

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month21 days, 2 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question