Solved

Create Batchfile to copy todays files

Posted on 2009-04-09
5
516 Views
Last Modified: 2012-05-06
Dear Sir/Madam

First of all sorry about my english. I am from belgium but i do my best. I want to make a Batch File that copies all files from a directory to an other made the same day i run the batch.

For example : Today i've made a file called "test" in a map that contains also "test0" made yesterday. Today i also run the batch and the batch copies only "test" because this is the only file that has been made today. I do not want to change the day everythime when i want to run the batch.

Can sombody help me with that script ?
I know a little about scripting and variables. But this goes way above my head ..
0
Comment
Question by:klaaspieters
  • 2
5 Comments
 
LVL 70

Accepted Solution

by:
garycase earned 63 total points
ID: 24105461
A simple XCopy script (with the /D:m-d-y parameter) would copy only files modified/created on or after the specified date; but this would require that you change the date every time you wanted to run the file -- which you indicated you don't want to do.

So I'd download and install XXCopy [http://www.xxcopy.com/index.htm#fw_pe ] ... free for personal use; nominal fee for commercial use ... and use the following command line:

XXCopy <Source Path> <Destination Path> /Do:.

This will copy only files created or modified "today" -- no matter when you run it.

For example, if you wanted to copy all files from your "My Documents" folder that were modified/created today to a "Backup" folder on drive X:, you would use:

XXCOPY  "C:\My Documents\"  X:\Backup\  /Do:.

There are numerous other options you could use to control the behavior of the copy ... but the simple line above is all you need to do what you described.   Note that any paths that contain spaces must be surrounded by quotes (as I've done with "C:\My Documents\"

The complete XXCopy technical reference is here (but it can be intimidating, as there are a LOT of switches -- you can make some VERY complex batch files with XXCopy):  http://www.xxcopy.com/index.htm#tbul
0
 
LVL 48

Assisted Solution

by:dbrunton
dbrunton earned 62 total points
ID: 24112334
Look at the following link.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_21670728.html

The solution there may be easier to implement.
0
 
LVL 7

Expert Comment

by:spamster
ID: 24309510
You can use RoboCopy - it comes with XP. You would just use a batch file similar to this

In my example I'm copying files from C:\CopyFrom to C:\CopyTo

@c:
@c:\
robocopy copyfrom copyto /MAXAGE:1

That should copy everything from the "copyfrom" directory thats a MAXimum of 1 day old into the "copyto" directory

So it should work every day without changing anything, or downloading any 3rd party apps

0
 
LVL 7

Expert Comment

by:spamster
ID: 24309517
Awww man!! I should've read that link first!!!
dbrunton sorry for trying to take your answer, haha
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

912 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now