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
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.
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.
Summary: Relates to an ealier post with title: Batch File deleting files by date? HAD TO CHANGE FOLLOWING TO GET WORKING 1. In Line: for /f "tokens=2" %%i in ('date /t') do set thedate=%%i Change tokens=2 to t...
Summary: I have created but not complete a vbscript that can move the oldest file by last modified date(not current date). The code is the following: Dim totFileCount,startFolder,folderdestination,objFile,tota...
Summary: Hi All I have a file that is created each day and always dumps as "Output", renamed as follows: @echo off for /f "tokens=1-4 delims=/ " %%d in ("%date%") do rename "C:\output.txt" output_%%d_%%e_%%f.t...