Page 1 of 1

List files modified since set date

Posted: 03 Aug 2018 03:28
by stephjo
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

Re: List files modified since set date

Posted: 03 Aug 2018 05:35
by Hackoo
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 :

Code: Select all

forfiles /m *.txt /d 0
And this will list all text files that have been modified in last 30 days :

Code: Select all

forfiles /m *.txt /d -30

Re: List files modified since set date

Posted: 03 Aug 2018 08:28
by Squashman
Hackoo wrote:
03 Aug 2018 05:35
And this will list all text files that have been modified in last 30 days :

Code: Select all

forfiles /m *.txt /d -30
That will find files older than 30 days.

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