Solved

robocopy append date to copied filename

Posted on 2012-03-23
11
1,281 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
Microsoft will be releasing the Windows 10 Creators Update in just a matter of weeks. Are you prepared? Follow these steps to ensure everything goes smoothly and you don't lose valuable data on your PC.
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

808 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