469,326 Members | 1,359 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

Script to copy files from one folder to another

Hi, I'm looking for a script to copy transaction log backup files from a network drive I have mapped to a local folder. Part of the filenames are common

dbname_tlog_datehour.trn (date is formated y/m/d and is 24 hour format ex: 1600, 1700, 1800....)

I've searched some perl forums and found a few scripts to try but haven't had any luck getting this working. Any help is appreciated.
Feb 4 '09 #1
3 34203
971 Expert 512MB
We don't have any scripts. Do you know perl? Have to tried to write the code yourself? Are you having problems with your code?

Feb 4 '09 #2
Thanks for the reply Kevin. I know very little perl. I forgot to post the code that I was trying to get working. I managed to figure to figure it out. I'll make sure to post the code and error next time.

Feb 11 '09 #3
174 Expert 100+
Here is one i made and use.

Expand|Select|Wrap|Line Numbers
  1. use File::Copy;
  3. $dir="\\\\Server\\logs\\"; # make sure you add the backslashes on the last directory
  4. opendir(DIR, $dir) or die "can't opendir $dir: $! \n";
  6. @files=readdir(DIR);
  7. closedir DIR;
  9. foreach $file (@files) {
  10.   if (-f "$dir$file") {  
  12. $moveloc="C:\\backup\\logs\\$file"; # Make sure the directory is already made.
  13. $old = "$dir$file";
  14. $new = "$moveloc";
  15. copy($old, $new) or die "Copy Faild: $!";
Feb 12 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Antonio Lopez Arredondo | last post: by
11 posts views Thread by Mike | last post: by
8 posts views Thread by Chris Strobel | last post: by
2 posts views Thread by Xavier Valdés | last post: by
2 posts views Thread by Dámaso Velázquez Álvarez | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.