Solved

robocopy append date to copied filename

Posted on 2012-03-23
11
1,278 Views
Last Modified: 2012-03-26
Using RoboCopy, is there a way to append something to the copied filenames?
I want to set up a backup system where it will back up a specific file, and append the day of the month to it so that I'll always have a month's worth of backups. I can get the day of the month, but how can I append it with RoboCopy?
Thanks!
0
Comment
Question by:etech0
  • 6
  • 5
11 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37758004
Create destination directories for each day of the month:

Robocopy C:\Folder1 X:\Folder%THISDAY%

Open in new window

0
 
LVL 10

Author Comment

by:etech0
ID: 37758007
That would be very unwieldy. As it's only one file, I'd rather have them all in one folder. Do you know if that's possible?
0
 
LVL 10

Author Comment

by:etech0
ID: 37758009
Maybe I'm better off using XCopy?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37758030
If it's only one file, Xcopy may be better.
0
 
LVL 10

Author Comment

by:etech0
ID: 37758040
With Xcopy, can I specify the copied file's filename?
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37758471
Yes:

Windows 2000 and XP xcopy syntax

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/EXCLUDE:file1[+file2][+file3]...]
source	Specifies the file(s) to copy.
destination	Specifies the location or name of new files.

Open in new window

0
 
LVL 10

Author Comment

by:etech0
ID: 37765905
Hi!
When I run the batch file, it tells me:

Does C:\Users\me\Desktop\file2.txt specify a file name
or directory name on the target
(F = file, D = directory)?

Can I tell it from within the batch file that it will be a file? I want this to be able to run without user interaction required.
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 37767012
You may need to pre-create the directories.
Or do this:
 
XCOPY C:\Folder1\MyFile_%THISDAY%  X:\Folder2\
rem ---- Add a backslash here ---------------^

Open in new window

0
 
LVL 10

Author Comment

by:etech0
ID: 37767161
The directory is already there!

Here is my test code:

XCOPY C:\Users\me\Desktop\file.txt C:\Users\me\Desktop\file2.txt

Open in new window

0
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 500 total points
ID: 37767261
Then just use "copy" (not xcopy).
0
 
LVL 10

Author Closing Comment

by:etech0
ID: 37767327
Nice!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

803 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