List files modified since set date

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
stephjo
Posts: 4
Joined: 03 Feb 2014 02:39

List files modified since set date

#1 Post by stephjo » 03 Aug 2018 03:28

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

Hackoo
Posts: 63
Joined: 15 Apr 2014 17:59

Re: List files modified since set date

#2 Post by Hackoo » 03 Aug 2018 05:35

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

Squashman
Expert
Posts: 4093
Joined: 23 Dec 2011 13:59

Re: List files modified since set date

#3 Post by Squashman » 03 Aug 2018 08:28

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

Post Reply