Move files after n days

Hello everyone,

I have a script that moves files after 60 days from the FTP folder over to a trash folder which is not accessible by the FTP. From there I can delete the files whenever the drive get’s full. That works fine so far.
The only thing that bothers me is that files moved to “.Trash” are not in any folder structure anymore (one big directory with the deleted files in it).

When I do a “ls -la” on the array {} I see the file names including the folders. I’m not sure if the find command or the mv command forgets about the directories.

This is the script:
bash -c ‘date;find /Volumes/data1/test/ -mtime +60 -type f -exec mv {} /Volumes/data1/.Trash/ ;;date’ >> ~/mylog

I’m glad for any help.

Thank you,
Felix

Shouldn’t be to difficult to analyze. First find out if the find command gives you what you think it gives you:

find /Volumes/data1/test/ -mtime +60 -type f

Every item in that list will be the subject of an mv command. You can see for yourself if, when being in the correct working directory, these willl be the mv commands you expected

The “problem” is the mv command which ignores any directory prefix in the source argument. mv is not equipped to create destination directories following the source pathname.

You’ll have to figure out another way to do this. One way would be to do it in two steps, first copy the source to destination, taking into account the directory prefix, then delete the source. cp with the --parents argument can do this, as can rsync.

Happy manual reading.