Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
My best effort is: ls -Rlt – dublintech May 28 '12 at 11:23

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).

share|improve this answer

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

share|improve this answer
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 '15 at 11:59
Sorry, I just tried to be useful... – mirekbarton Apr 1 '15 at 19:38

You must log in to answer this question.

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