Results 1 to 4 of 4
Hi,
I want to be able to copy directories from one location to another.
Such as /webmain/tmb
I want to write a script that will copy all the directories(including sub ...
- 09-03-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 2
Copy Directories based on Modified Date
Hi,
I want to be able to copy directories from one location to another.
Such as /webmain/tmb
I want to write a script that will copy all the directories(including sub files) from within that folder that were modified within a given month and transfer them to a folder under the tmb folder with the month identifier as the directory name.
/webmain/tmb/June-2010
What copy functions should I look at to take care of this? Are there any good examples of starter scripts out there?
Any advice would be greatly appreciated!
Darthvader
- 09-03-2010 #2Just Joined!
- Join Date
- Aug 2010
- Posts
- 18
Code:folder=/webmain/tmb/$( date +%B-%Y ) mkdir $folder for file in $( find /directory_path -mtime -30 -print) ; do cp $file $folder ;done
- 09-04-2010 #3Just Joined!
- Join Date
- Sep 2010
- Posts
- 2
Barbus,
Thanks for the reply. Do I need to set this up in a script, or can i execute this directly from ssh?
- 09-04-2010 #4Just Joined!
- Join Date
- Aug 2010
- Posts
- 18
It should work independently of way you use it.
But I suppose it would be more comfortably to run it as script by cron.
Also please draw attention that this script finds only files changed for last 30 days and not 31 or 28.


Reply With Quote