Jorge Vega Sánchez
Jorge Vega Sánchez

Reputation: 7590

Copy/move all files which last modified date are in a given month

I have a question about terminal command. At work, we receive in a folder many files everyday. Today we decide to organize this full amount of files collecting them in folders using year and month as a rule.

Question, how can i move all the files which last modified date are in the range of the month of April of 2013, for example.

Upvotes: 1

Views: 1588

Answers (1)

rici
rici

Reputation: 241741

You can easily select files whose modification times are in a time range with the find command. Here's an example with gnu find, which makes this fairly simple:

find . -newermt 'Apr 1, 2013 00:00' -not -newermt 'May 1, 2013 00:00' \
       -exec mv -t /path/to/April_2013/directory '{}' '+'

man find for all the gory details.

Upvotes: 4

Related Questions