Background
I need to find files that I have worked on lately.
OS
OS Linux
Find Command
Samples
Sample – Find Files modified In the Last 3 Days
Outline
- Folder
- Folder is .
- . here means current folder
- Folder is .
- Type
- Type is f
- Type is f as in file
- Type is f
- iname
- iname means case insensitive name
- iname is *.sql
- iname means case insensitive name
- mtime
- mtime means modification time
- mtime -N ( -3 ) means modified in the last N ( 3 ) days
- mtime means modification time
Code
find . -type f -iname *.sql -mtime -3
MS Windows ( MS DOS )
Find Command
The Find command does not have an option that considers date.
ForFiles Command
Samples
Sample – Find Files Touched Since Specific Date
Outline
- /P
- Path is .
- . here means current folder
- Path is .
- Sub Folder
- /S
- Include sub-folder
- /S
- File Mask
- /M stands for file mask
- .M is *.sql
- /M stands for file mask
- /D
- /D is file’s modification time
- +06/07//2022 means file’s modified since 2022-June-6th
- –06/07//2022 means file’s modified prior to 2022-June-6th
- /D is file’s modification time
Code
forfiles /P . /S /M *.sql /D +06/07/2022
Explanation
- Output Format
- “Bare” File Names returned
- Folder Structure is not returned
Sample – Find Files Touched Prior To Number of Days
Outline
- /P
- Path is .
- . here means current folder
- Path is .
- Sub Folder
- /S
- Include sub-folder
- /S
- File Mask
- /M stands for file mask
- .M is *.sql
- /M stands for file mask
- /D
- /D is file’s modification time
- -3 means file’s modified prior to 3 days ago
- /D is file’s modification time
Code
forfiles /P . /S /M *.sql /D -3
Sample – Find Files Touched Post N Days
Outline
- /P
- Path is .
- . here means current folder
- Path is .
- Sub Folder
- /S
- Include sub-folder
- /S
- File Mask
- /M stands for file mask
- .M is *.sql
- /M stands for file mask
- /D
- /D is file’s modification time
- +0 means file’s modified since the the beginning of the current day
- /D is file’s modification time
Code
forfiles /P . /S /M *.sql /D +0
Summary
Unfortunately, the Microsoft’s implementation has significant short comings.
Find
- Does not have a date argument
ForFiles
- Absolute Dates
- Supports absolute date
- To flag prior files, precede absolute date with minus sign ( – )
- To flag successive files, precede absolute date with minus sign ( + )
- Supports absolute date
- Relative
- Supports tagging files pre N days
- Does not support tagging files post N days
- Except when N is zero ( 0 ) days
- For Today, you will pass in 0
- Except when N is zero ( 0 ) days
References
- ForFiles
- ForFiles
Link
- ForFiles