dareach
asked on
shell script to move files older that 30 days to another folder
i need a script that i can have cron run everyday to move our order files older than 30 days into another folder containing all the orders over 30 days.
i want to keep the amount of orders in our order folder down to about 3000 and we can do that by eliminating them by dates older that 30 days. anything above that and we start seeing big performance reductions.
i want to keep the amount of orders in our order folder down to about 3000 and we can do that by eliminating them by dates older that 30 days. anything above that and we start seeing big performance reductions.
find /path/to/orderfolder -mtime +30 -exec mv {} /path/to/otherfolder \;
ASKER
how can i make it overwrite duplicates?
Is it not doing that?
ASKER
its asking me yes or no for each file it has to overwrite
find /path/to/orderfolder -mtime +30 -exec mv -f {} /path/to/otherfolder \;
ASKER
hey man, thanks for your help. i should have said this earlier. the folder im having look at is a folder with a bunch of other folders in it contaning order files, after 30 days it starts getting really big and slow so im trying to get a script that will move the folders with dates older than 30 over to another folder.
here is one line of the thousands returned by the script:
mv: rename /Volumes/Email Server_HD/OrderFiles/Tempo rary Items/501/Temporary Items to /Volumes/Email Server_HD/OrderFiles/*Arch ives/Tempo rary Items: Permission denied
can we have it only copy visible folders?
thanks,
brandon
here is one line of the thousands returned by the script:
mv: rename /Volumes/Email Server_HD/OrderFiles/Tempo
can we have it only copy visible folders?
thanks,
brandon
What are the visible folders? How are they distingushed from non-visible folders?
ASKER
mv: rename /Volumes/Email Server_HD/OrderFiles/Tempo rary Items/501/Temporary Items
why is it trying to copy this, isnt that an invisible file? i dont want it to effect any hidden files in the directory its copying to. just the folders you can see which is what im trying to have copied over.
why is it trying to copy this, isnt that an invisible file? i dont want it to effect any hidden files in the directory its copying to. just the folders you can see which is what im trying to have copied over.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i just ran the script again and it looked in the folders and moved everything older than 30 days to the archive folder, now i have an archive folder with files instead of folders containing files. i need it to just look at the folder dates not the contents, then move the folder if its older than 30 days...
find /path/to/orderfolder -d -mtime +30 -exec mv -f {} /path/to/otherfolder \;
ASKER
find /path/to/orderfolder -d -mtime +30 -exec mv -f {} /path/to/otherfolder \;
OS returns this "find: -d: unknown expression primary"
OS returns this "find: -d: unknown expression primary"
sorry -d shoud be
-type d
-type d