Solved

Create Batchfile to copy todays files

Posted on 2009-04-09
5
530 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
[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
  • 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 49

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
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.

628 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