Solved

Create Batchfile to copy todays files

Posted on 2009-04-09
5
513 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
Comment Utility
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 47

Assisted Solution

by:dbrunton
dbrunton earned 62 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Awww man!! I should've read that link first!!!
dbrunton sorry for trying to take your answer, haha
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

744 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

19 Experts available now in Live!

Get 1:1 Help Now