Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello everyone,
I need to come up with a batch script that can search the c: directory for file(s) that were modified today or within a week.
Do I have to search the file in c: using date so I could come up with list of files?
Kindly help
Sufian

This may need tweaking to accomodate the date style on your box.
Processing files a week old will take more doing.
===============================
:: 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
)
=====================================
If at first you don't succeed, you're about average.M2

Hi M2,thank you for the suggestion.
I try the script but it doesnt seem to work on my system. I am not that familiar with FOr command and I am having trouble understanding them.
For the 2nd part of the scipt, does it meant to convert the delimeter of the %Temp% to set mydate. I need something that can list the files from a specific date. Can you suggest to me any alternatives?
for /f "tokens=* delims= " %%a in ('dir /s/b %TEMP%\#') do (
set mydate=%%~Ta
)

Do this and post result.
======================
@echo off > %TEMP%\#
setLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%a in ('dir /s/b %TEMP%\#') do (
set mydate=%%~Ta
echo !mydate!
)
=====================================
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 |