Skip to content

Instantly share code, notes, and snippets.

@dalang
Created May 11, 2013 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalang/5560630 to your computer and use it in GitHub Desktop.
Save dalang/5560630 to your computer and use it in GitHub Desktop.
##file operation## delete tmp bakup files under windows(file name end with '~') add extension name to all file under dir .
#! usr/bin/perl
@files = <*>;
if (!$_[0]) {
$extension = '.png';
} else {
$extension = $_[0];
}
foreach $file (@files) {
print $file;
if (not $file =~ /\./) {
$newfile = $file . $extension;
rename $file, $newfile;
}
print " ".$newfile."\n";
}
#!/usr/bin/perl
use File::Find;
use Cwd;
$path = getcwd;
find(\&wanted, $path);
sub wanted {
if ($File::Find::name =~ /.+~$/) {
print "we will delete the backfile \"$File::Find::name\" \n";
unlink $File::Find::name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment