2

I need a way to search from a base folder, all the folders inside of that one recursively, and find all photos of JPG and PNG that were created before a certain date (01.Feb.2013) and then move them to a particular folder.

How would I go about this?

4

You could use find:

touch -t 201302010000 /tmp/a
find ~/directory \( -iname \*.jpg -o -iname \*.png \) -Bnewer /tmp/a \
    -exec mv {} ~/directory2 \;

touch -t normally changes only the modification and access times, but it also changes the creation time if the target time is before the original creation time or when you are creating a new file.

-Bnewer (for birth time / creation time) is not supported by GNU/Linux platforms which don't have metadata for the creation time.

The parentheses are needed because -a (and concatenating expressions without -a) has higher precedence than -o.

  • Thank you very much. I had an answer, but I couldn't see how to string it together. This is better and succinct. I like it. Thank you very much for the explanation too! – Danijel-James W Oct 5 '13 at 1:32
  • Very clever, as always. – beroe Oct 5 '13 at 5:22

You must log in to answer this question.

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