Created
May 11, 2013 17:09
-
-
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 .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! 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"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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