Computing.Net > Forums > Programming > Copy files by date modified

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Copy files by date modified

Reply to Message Icon

Name: grkdimi13
Date: November 14, 2007 at 02:26:00 Pacific
OS: XPsp2
CPU/Ram: 2.3/768
Product: xxx
Comment:

Hello,

I'm trying to copy files locally, from one directory to another. Is there a way for me to specify the copy command to copy files by date modified?

Example: I want to copy from X directory all the files that were modified XX/XX/XXXX to Y directory.



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: November 14, 2007 at 10:13:38 Pacific
Reply:

One way to do it (not necessarily a good way) is this:

for /f "tokens=3*" %%a in ('dir /a-d ^| findstr /b 14/11/2007') do copy %%b newfolder

Another way to do it uses pure batch commands (no external executables), the for command iterating files in the directory, using set timestamp=%~tF, set datestamp=!timestamp:~0,10! (with delayed expansion). I leave that as an exercise for the reader.


0

Response Number 2
Name: Mechanix2Go
Date: November 14, 2007 at 10:26:48 Pacific
Reply:

Hi klint,

Yours is better than what I came up with; it's simpler.


=====================================
If at first you don't succeed, you're about average.

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Copy files by date modified

Batch File deleting files by date? www.computing.net/answers/programming/batch-file-deleting-files-by-date/15581.html

Move the Oldest File by Last Modifi www.computing.net/answers/programming/move-the-oldest-file-by-last-modifi/14474.html

move file by date last modified in a batch www.computing.net/answers/programming/move-file-by-date-last-modified-in-a-batch/20173.html