Solved

robocopy append date to copied filename

Posted on 2012-03-23
11
1,298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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).
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
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.

623 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