1

I have windows 7 box with cygwin installed. I have multiple folders with files, within a single root folder. I want to find the list of files that have a time stamp within a specific date time range.

1
  • My best effort is: ls -Rlt
    – dublintech
    May 28, 2012 at 11:23

3 Answers 3

2

You can use the find command with the -newerXY option.

From man find:

-newerXY reference
Compares the timestamp of the current file with reference. The reference argument is normally the name of a file (and one of its timestamps is used for the comparison) but it may also be a string describing an absolute time. X and Y are placeholders for other letters, and these letters select which time belonging to how reference is used for the comparison.

The possible values for X and Y are as follows:

  • a - last access time of current file or reference
  • B - birth time of current file or reference
  • c - last inode status change time of current file or reference
  • m - last modification time of current file or reference
  • t - reference is a string representing a timestamp (not valid for X)

X refers to the current file and Y to the reference, so you'll want to use 'm' for the first letter (current file's modification date) and 't' for the second (timestamp passed as a string). Example script:

find . -type f -newermt "2012-05-01" ! -newermt "2012-05-15"

This finds all files that were modified between 1 and 15 May 2012. The ! (logical NOT) operator reverses the meaning of the argument following it - if -newerXY means "X is newer than Y", then ! -newerXY means "X is older than Y".


An alternative option, since you're on Windows, is to use Powershell. The Get-ChildItem cmdlet returns all files in a given folder (recursively, if desired), and the Where-Object cmdlet allows you to filter the output of other commands. Example script (assuming the directory you want to search is the current directory):

Get-ChildItem -Recurse | Where-Object { $_.LastWriteTime -ge "2012-05-01" -and $_.LastWriteTime -le "2012-05-15" -and !$_.PSIsContainer }

This returns all files modified between 1 and 15 May 2012. You can use CreationTime instead of LastWriteTime to check for file creation time instead. The !$_.PSIsContainer filter only returns files (PSIsContainer is true for folders, and the exclamation mark is again the logical NOT operator).

0

You can use Far Manager, Find File with filter: enter image description here

Hit the filter button, an press Insert to insert new filter:enter image description here

Name the filter somehow, enter file mask, check Date/Time, select value change, uncheck Relative and enter the date/time ranges: enter image description here

Hit ok, and in the Filters menu, press space to select the filter (+ should appear next to the filter): enter image description here

Press enter, and hit Find: enter image description here

Search results (in this example photos - mask IMG_*.jpg - date range for June 2022): enter image description here

-1

It is also possible to find that files with GUI File Explorer. Some examples:

datemodified:2015-02-18 08:00..2015-02-18 13:00
datemodified:>2015-02-18 08:00
datemodified:<2015-02-18 08:00

And some further reading: Advanced tips for searching in Windows, Using Advanced Query Syntax Programmatically

2
  • We expect high quality answers here at Superuser which means answers should include ALL relevant information not just links to external resources.
    – Ramhound
    Mar 31, 2015 at 11:59
  • Sorry, I just tried to be useful... Apr 1, 2015 at 19:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .