Ubuntu – How to move files older than X to another folder

archivefiles

How do I move files older than 30 days from folder /storage/current/dbdumps/ to /storage/archive/dbdumps?

I tried:

find /storage/current/dbdumps/ -type f -mtime +30 -exec mv '{}' /storage/archive/dbdumps \;

but seems invalid in Ubuntu 11.04.

Best Answer

The command seems ok and in my 11.10 it works. Haven't you missed the trailing slash in the destination folder?

find /storage/current/dbdumps/ -type f -mtime +30 -exec mv '{}' /storage/archive/dbdumps/ \;

Other thing you may try is using /bin/mv insted of just mv.