Skip to content

Instantly share code, notes, and snippets.

@thinkhy
Created January 11, 2011 13:13
Show Gist options
  • Save thinkhy/774395 to your computer and use it in GitHub Desktop.
Save thinkhy/774395 to your computer and use it in GitHub Desktop.
CopyFile_Perl
####################################################################################
# Description: Copy error files to another directory
# Usage:
# Creator: thinkhy
# Date: 2010.01.13
####################################################################################
use strict;
use warnings;
use Cwd;
use File::Copy;
open IN, "<error.txt";
while(<IN>)
{
print $_."\n";
my $filename = $_;
chomp($filename);
$filename =~ s/\//\\/g;
my($dirpath,$basename,$extname) = ($filename =~ /^((?:.*[:\\\/])?)(.*)(\.[^.]*$)/s);
#$filename = "\"".$filename."\"";
my $curdir = getcwd;
$curdir =~ s/\//\\/g;
my $dst = $curdir."\\出错图片\\$basename".$extname;
$dst =~ s/[\r\n]//g;
copy $filename, $dst
or warn "从\"$filename\"拷贝到\"$dst\"出错\n";
}
close IN;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment