IMHO, this is a non-trivial problem to do it right - at least for me :). I will be happy if someone with a more experienced post becomes a better solution.
script: (GNU must be found if your "find" is the version of the GNU version that gfind needs to find)
FROMDIR="/mnt/third/bt/uploads"
TODIR="/mnt/third/bt/tmp"
tmp="/tmp/movelist.$$"
cd "$FROMDIR"
gfind . -depth -mtime +7 -printf "%Y %p\n" >$tmp
sed 's/^. //' < $tmp | cpio --quiet -pdm "$TODIR"
while read -r type name
do
case $type in
f) rm "$name";;
d) rmdir "$name";;
esac
done < $tmp
Explanation:
- , ( ) tmpfile (find)
- tmp (cpio)
- , , dirs - tmpfile (while...)
script , fifo .. zilion , , ( SUBDIRS)
DRY RUN !:)