Writing Script to Copy Newest Directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Writing Script to Copy Newest Directory
# 1  
Old 11-26-2011
Writing Script to Copy Newest Directory

I am trying to write a script that once executed it will search within a directory and copy only the newest directory that has not been copied before to a new location. Kind of like what ROBOCOPY /M does in windows?

The directories are not left in the new location so using a sync action won't really work.

Thanks
# 2  
Old 11-27-2011
You want an application called rsync, it can be configured to look for the newest file or directory. Otherwise, you will have to create a file/database to keep track of which ones you have copied, and work off that. rsync will just look for directories (of a specified format) that do not exist on the destination directory.
# 3  
Old 11-27-2011
I have heard of RSync before. The problem is that after the folders are copied the copy doesn't stay where it is. it is automatically moved to a new location so would rsync would be copying all files from the original directory every time?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copy the newest file from a different server to your home server.

Hi all, So I am on server 1, and I want to grab the newest file from a particular directory on server 2, and place this in a directory on server 1. I am trying to use: ls -tr | tail -1 This works, and gets me the newest file in a particular directory. Using svn `ls -tr | tail -1` etc I... (1 Reply)
Discussion started by: Lexx87
1 Replies

2. Shell Programming and Scripting

Script to Poll Directory and Copy files

Hi all, I'm looking for a script to poll a specified directory and copy new files to another location. The script should only copy new files so, I based on mtime I guess? Can anyone point me in the right direction of a script which could do this? My scripting skills aren't too bad, but... (1 Reply)
Discussion started by: JayC89
1 Replies

3. Shell Programming and Scripting

error in sh script while copy files to a backup directory

I am trying to copy files from one directory to another using shell script. Can anyone please troubleshoot the code. thanks in advance... #!C:\Shell\sh.exe files_dir="C:\Documents and Settings\scripts\files" backup_dir="C:\Documents and Settings\scripts\ztest" echo cding to... (2 Replies)
Discussion started by: sureshcisco
2 Replies

4. Shell Programming and Scripting

copy result of ls -ltrh script into a different directory

i have a working bash script to list filename from multiple directories. Would you know how can i copy the result of ls -ltrh into a different directory? sample: ls -ltrh /dir1 /dir1/dir2 |grep $KEYWORD thank you (2 Replies)
Discussion started by: lhareigh890
2 Replies

5. Shell Programming and Scripting

Get the newest file in a directory.

I am new to shell scripting so i need some help need how to go about with this problem. I have a directory which contains files in the following format. The files are in a diretory called /incoming/external/data AA_20100806.dat AA_20100807.dat AA_20100808.dat ... (4 Replies)
Discussion started by: ziggy25
4 Replies

6. Shell Programming and Scripting

Perl script to copy last directory

Hi, Plaese help me with perl script which copies the latest directory This is a double post. Continue at your original thread. Thanks. (0 Replies)
Discussion started by: shaveta
0 Replies

7. Shell Programming and Scripting

finding the 5 newest files in a directory

I have a folder that has new files created everyday, is there a way i can filter them so that only the 5 newest files are displayed? I'm hoping this can be done by a one liner without a script. for example my directory contains -rw-r--r-- 1 root root 0 Jun 24 08:34 file112 -rw-r--r-- 1 root... (2 Replies)
Discussion started by: zerofire123
2 Replies

8. Shell Programming and Scripting

Shell script for a writing the directory structure to a file

Hi All, I am new user of shell scripting has come up with a problem. that I have a directory structure like : Home | |--------A | |----trunk | |-------A_0_1/ | | | |-------A_0_2/ | |--------B | ... (6 Replies)
Discussion started by: bhaskar_m
6 Replies

9. Shell Programming and Scripting

writing script to clean up a directory

I have to do a directory clean up on several machines. The task is as follows: go to a particular directory (cd /xxx) 1. create a directory ' SCRIPTCLEANUP ' ( i KNOW IT) loop through 2. List the directory 3. if directory and start with 'DQA' leave it, 4. if directory or file move it to... (0 Replies)
Discussion started by: ajaya
0 Replies

10. Shell Programming and Scripting

Script to cd into newest (dated) FTP directory

I have written the following simple bash script. It logs onto an FTP site and then CDs into a directory that corresponds to the last business day. So for example the directory I would access today is 20060110 (2006 jan 10). I am currently taking today's date and subtracting 1, putting this... (3 Replies)
Discussion started by: steved
3 Replies
Login or Register to Ask a Question