Solved

Create Batchfile to copy todays files

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Move windows 10 users 8 71
URGENT: Re-install Windows 10 using same license? 18 74
AD architecture diagram 5 34
Windows XP and a 3TB drive that Windows cannot see 19 34
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

856 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