Solved

Create Batchfile to copy todays files

Posted on 2009-04-09
5
526 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 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

733 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