Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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?

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"

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 EnableDelayedExpansionfor /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

![]() |
![]() |
![]() |

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