Created
November 10, 2012 21:12
-
-
Save moccos/4052512 to your computer and use it in GitHub Desktop.
[Perl] Rename downloaded file like "file(1).zip"
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 | |
while(1) { | |
foreach(<*(1)*>) { | |
next if (/\.crdownload$/); | |
/(\S+)\s?\(\d\)(\.[^\.]+)?$/; | |
$new_name = "$1$2"; | |
if (rename($_, $new_name)) { print "$_ -> $new_name\n"; } | |
#else { print STDERR "failed to rename: $_"; } | |
} | |
sleep(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment