I want to find images, from a directory, that were added in last 1 year and copy them to a new directory preserving original folder structure.
I am using find but it is not copying anything. is there any way it can be done using 1 line command?
find image/* -mtime +356 -exec cp {} modified-last-year/ \;
I am in the image directory when running this command and i want to only search image folder recursively.
[EDIT]
After the two answers I did following.
1. find image/* -mtime +356 | cpio -pd /target_dir
I get 0 Blocks.
find /full/path/to/image -mtime 365 -type f ( "-name *.jpg -o -name *.gif ) -execdir cp {} /full/path/to/image_target_dir/modified-last-year \;
ANDfind /full/path/to/image -mtime 365 -type f -execdir cp {} /full/path/to/image_target_dir/modified-last-year \;
Nothing copied.AND simply find to get count of files with and without -type f.
find /full/path/to/image -mtime 365 -type f | wc -l
i get 0.I could verify that there are indeed files with in image dir and in sub directories which were added in last 1 yr. infact there should be more than 200 images.
[EDIT 2]
I have to also exclude one directory from find so the following code worked fine.Thanks to 1st answer, i was able to create this.
find /full/path/to/image/* -path /full/path/to/image/ignored_dir -prune -o -print -mtime -365 | cpio -pd /full/path/to/target_dir/modified-last-year