]> Sergey Matveev's repositories - torn.git/blobdiff - torn
Really raise copyright years
[torn.git] / torn
diff --git a/torn b/torn
index 55822266cbd0bab69bd39f2b8b5d7c28ef7b4bb7..5db4688f851ebad6a648a29e1297bf4b40b674d0 100755 (executable)
--- a/torn
+++ b/torn
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 # torn - Musical files renaming with russian language transliteration
-# Copyright (C) 2007-2020 Sergey Matveev (stargrave@stargrave.org)
+# Copyright (C) 2007-2021 Sergey Matveev (stargrave@stargrave.org)
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -59,14 +59,14 @@ use Encode;
 
 binmode STDOUT, ":utf8";
 
-my $VERSION = "0.9";
+my $VERSION = "0.10";
 
 my $src;
 my $dst;
 my $src_filename;
 
 if ($#ARGV >= 0) {
-    print "torn version $VERSION, Copyright (C) 2007-2020 Sergey Matveev
+    print "torn version $VERSION, Copyright (C) 2007-2021 Sergey Matveev
 torn comes with ABSOLUTELY NO WARRANTY.  This is free software,
 and you are welcome to redistribute it under certain conditions.\n
 Usage: just run inside the directory. Look for POD inside the script itself.\n";
@@ -112,18 +112,18 @@ foreach (sort readdir DIR) {
     $dst =~ s/Ю/Ju/g;
 
     # Lowercase file extensions
-    if($dst =~ /^(.*)\.([^\.]+)$/){
+    if ($dst =~ /^(.*)\.([^\.]+)$/) {
         $dst = $1 . "." . lc $2;
     };
 
     # Change looking of track numbers
-    # And renaming itself
-    if($dst =~ /^(\d+)\-(.+)$/){
-        print "$src -> $1.$2\n";
-        rename $src_filename, "$1.$2";
-    } else {
-        print "$src -> $dst\n";
-        rename $src_filename, $dst;
+    if ($dst =~ /^(\d+)[-.]_*(.+)$/) {
+        $dst = "$1.$2";
     };
+
+    next if ($src_filename eq $dst);
+    print "$src -> $dst\n";
+    die "\"$dst\" exists" if -e $dst;
+    rename $src_filename, $dst;
 };
 closedir DIR;