

This (i.e., /usr/bin/[), and not the shell's [ builtin, is what find runs when you use -exec [. man \[ and 16.3 test: Check file types and compare values in the Coreutils docs.man mv and the GNU Coreutils reference manual (especially 11.4 mv: Move (rename) files).man find and the GNU Findutils reference manual.Then find evaluates the next -exec expression, which prints the warning message.

But if [ returned false, the file is still there. If [ returned false, then the file is gone, so it was moved, so there's no need to do anything. (Many commands' exit statuses are best interpreted as signifying success or failure, but ['s exist status is usually best interpreted as true or false.)

you can run: find srcdir -type f -newermt ! -newermt -exec mv -i ) exists (and is a regular file), and returns either true/success or false/failure. last modified in (for example) September 2014.anywhere in srcdir (i.e., including its subdirectories, their subdirectories, etc.).T:W will make the command use file modified time.Moving the files, and prompting the user when there are duplicate names:Īs Subv3rsion's and Eric Leschinski's answers show, the -newermt predicate selects files modified more recently than the date (and optional time) specified as its operand. O:D will make the command print the files list using the file date/time attributes.

It would print the recently modified file at the bottom. It would print the list of files in the order of file modified time. You can run the below command to find the latest modified file in a directory. This makes it easier to select a range that spans multiple months. Click one date and then Shift-click another date. This is the easiest option if your range falls within a month. To search a range of dates, you have a few options: Click a date and drag your mouse to select the range. forfiles /M *.pdf /C "cmd /c echo How to find the last modified file in a directory? Click any date to search for files modified on that day. For example, to get modified time/date only for pdf files, we can use the below command. forfiles /C "cmd /c echo can restrict the command only to certain files using * command. Using forfiles command we can get modified date and time for all the files in a directory. To get modified date/time only for files in the current directory(i.e exclude directories from files) dir /T:W /A:-D Using Forfiles command
