Find directory older than x and mv directory with sub files command
Hi guy's, I'm quite new to linux but I have configured a simple ftp server and it's working great. I have a FTP-Shared folder with upload and download subfolders. Under upload's and download's I have identical category subfolders like mp3's, movies, software etc. in both. As the guy's upload, I would like to create a line crontab where I can move all the content under /FTP-Shared/upload/mp3/* older than 14 day's to FTP-Shared/downloads/mp3/ recursively (Like in cp command), but the timestamp must be searched on the first directory and not sub files example: /mp3/Club Dance/CD1/Hallo world.mp3
This is how far I got: [root@clients ~]# /usr/bin/find /FTP_Shared/upload/Mp3s/ -depth -mindepth 1 -mtime +14 -type d -exec mv -f {} /FTP_Shared/download/Mp3s/ \; This command moves the directory and files, but it is not recursively Any ideas would be great!! Thanks in advance |
If you manually type the command part:
Code:
# substitute the appropriate source directory, of course --- rod. |
If I use the mv command manually, it works. It is only when I use the find command where it finds all the files and folders timestamp and moves them accordingly. It does not move the like in the manual command (recursion). Could I maybe use the grep command to find the 1st directory and the get the timestamp of that and then try to move it with all subdirectory’s and files?
Regards |
Okay, maybe what is happening is that find is reporting the found directories in a depth-first order, so the lower directories are being moved first. To diagnose, insert the 'echo' command in front of 'mv', so you can see what is happening:
Code:
/usr/bin/find /FTP_Shared/upload/Mp3s/ -depth -mindepth 1 -mtime +14 -type d -exec echo mv -f {} /FTP_Shared/download/Mp3s/ \; --- rod. |
Thanks for the advice, I'll have a look into that.
|
All times are GMT -5. The time now is 11:49 AM. |