Hello Fellow Batch File Enthusiasts,
I am seeking help to write a batch file that lists only those .txt files modified on or since a given date, say 07/15/2018.
Could you please help me?
@echo off
for /f "delims=" %%a in ('dir *.txt /o:d') do (
set fileLine=%%a
set fileDate=!fileLine:~0,10!
if !fileDate! gtr 07/15/2018 echo "%%a"
)
Thank you,
-Steph
List files modified since set date
Moderator: DosItHelp
Re: List files modified since set date
You can take a look at this ==> https://stackoverflow.com/questions/934 ... batch-file
Use FORFILES /? from the command line to get documentation on its use.
This simple command will list all text files that have been modified today :
And this will list all text files that have been modified in last 30 days :
Use FORFILES /? from the command line to get documentation on its use.
This simple command will list all text files that have been modified today :
Code: Select all
forfiles /m *.txt /d 0
Code: Select all
forfiles /m *.txt /d -30
Re: List files modified since set date
That will find files older than 30 days.Hackoo wrote: ↑03 Aug 2018 05:35And this will list all text files that have been modified in last 30 days :Code: Select all
forfiles /m *.txt /d -30
If you want to find files modified in the last 30 days you would need to first figure out what the date was 30 days and feed the date to FORFILES.
Code: Select all
forfiles /m *.txt /d +07/04/2018