Computing.Net > Forums > Programming > Copy files that are dated

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 that are dated

Reply to Message Icon

Name: destini
Date: July 26, 2007 at 07:58:50 Pacific
OS: Windows XP
CPU/Ram: Pent 2.13 GHz, 2 gig ram
Product: dell
Comment:

I have a file that is dated each day, such as H324726, 726 being the date. How can I script this to copy to a new folder everyday without grabbing past dated files?




Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 26, 2007 at 08:21:48 Pacific
Reply:

To grab the most current file:
FOR /F "DELIMS=" %%a IN ('DIR /B /A-D /OD') DO SET copyMe="%%a"
MD "New Folder"
COPY %copyMe% "New Folder"


0

Response Number 2
Name: Mechanix2Go
Date: July 26, 2007 at 19:16:43 Pacific
Reply:

Razor2.3 is right, as usual.

To process today's files, try this:


::== only today's
:: process only today's files

@echo off > %TEMP%\#
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir /s/b %TEMP%\#' ) do (
set mydate=%%~Ta
)

for /f "tokens=1 delims= " %%a in (' echo !mydate!' ) do (
set today=%%a
)

for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
set TD=%%~Ta
for /f "tokens=1 delims= " %%a in ('echo !TD!') do (
set filedate=%%a
)
if !filedate! equ !today! echo process %%a
)
::== DONE


=====================================
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 that are dated

copy Files based on date www.computing.net/answers/programming/copy-files-based-on-date/19800.html

Passing prior date into a variable www.computing.net/answers/programming/passing-prior-date-into-a-variable/15571.html

copy files of a particular date www.computing.net/answers/programming/copy-files-of-a-particular-date/14483.html