By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,373 Members | 1,984 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,373 IT Pros & Developers. It's quick & easy.

Script to copy files from one folder to another

P: 2
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
Share this Question
Share on Google+
3 Replies


eWish
Expert 100+
P: 971
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?

--Kevin
Feb 4 '09 #2

P: 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.

Ange
Feb 11 '09 #3

Icecrack
Expert 100+
P: 174
Here is one i made and use.

Expand|Select|Wrap|Line Numbers
  1. use File::Copy;
  2.  
  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";
  5.  
  6. @files=readdir(DIR);
  7. closedir DIR;
  8.  
  9. foreach $file (@files) {
  10.   if (-f "$dir$file") {  
  11.  
  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.