Renamer 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/renamer +7 -1
- data/doc/ChangeLog +11 -1
- data/doc/TODO +1 -1
- data/doc/renamer +5 -1
- data/lib/const.rb +1 -1
- data/lib/renamer.rb +42 -0
- data/po/fr/renamer.po +29 -21
- data/po/renamer.pot +29 -21
- data/test/tc_renamer.rb +52 -0
- metadata +2 -2
data/bin/renamer
CHANGED
@@ -78,13 +78,14 @@ opts.on("-d", "--downcase", _("Downcase FILENAMES")) { action = :downcase }
|
|
78
78
|
opts.on("-u", "--upcase", _("Upcase FILENAMES")) { action = :upcase }
|
79
79
|
opts.on("-c", "--capitalize", _("Capitalize FILENAMES")) { action = :capitalize }
|
80
80
|
opts.on("-w", "--word", _("Capitalize each words in FILENAMES")) { action = :word }
|
81
|
+
opts.on("--downcase_ext", _("Downcase FILENAMES extensions")) { action = :downcase_ext }
|
82
|
+
opts.on("--upcase_ext", _("Upcase FILENAMES extensions")) { action = :upcase_ext }
|
81
83
|
opts.on("-s", "--space", _("Replace spaces by underscores in FILENAMES")) { action = :space }
|
82
84
|
opts.on("-U", "--underscore", _("Replace underscores by spaces in FILENAMES")) { action = :underscore }
|
83
85
|
opts.on("-b", _("--basename BASENAME"), _("Rename FILENAMES using the specified"), _("BASENAME followed by an incremental number")) { |bn| action = :basename; arg = bn }
|
84
86
|
opts.on("-e", _("--ext NEW"), _("Rename FILENAMES from their actual extension"), _("to the NEW one")) { |new| action = :ext; arg = new }
|
85
87
|
opts.on("-r", "--recursive", _("Run %s recursively across directories") % Const::NAME) { recursive = true }
|
86
88
|
opts.on("-o", "--overwrite", _("Overwrite existing files if needed") % Const::NAME) { overwrite = true }
|
87
|
-
opts.on("-V", "--verbose", _("Run %s in verbose mode (quiet by default)") % Const::NAME) { $VERBOSE = true }
|
88
89
|
|
89
90
|
opts.separator ""
|
90
91
|
opts.separator _("Common options:")
|
@@ -92,6 +93,7 @@ opts.separator _("Common options:")
|
|
92
93
|
opts.on("-h", "--help", _("Show this help")) { puts opts.to_s; exit(0) }
|
93
94
|
opts.on("-v", "--version", _("Show %s version") % Const::NAME) { puts Const::NAME + " v" + Const::VER; exit(0) }
|
94
95
|
opts.on("-l", "--license", _("Show some information about %s license") % Const::NAME) { puts Const::LICENSE; exit(0) }
|
96
|
+
opts.on("-V", "--verbose", _("Run %s in verbose mode (quiet by default)") % Const::NAME) { $VERBOSE = true }
|
95
97
|
|
96
98
|
###################
|
97
99
|
# Parsing options #
|
@@ -112,6 +114,10 @@ when :downcase
|
|
112
114
|
r.downcase
|
113
115
|
when :upcase
|
114
116
|
r.upcase
|
117
|
+
when :downcase_ext
|
118
|
+
r.downcase_ext
|
119
|
+
when :upcase_ext
|
120
|
+
r.upcase_ext
|
115
121
|
when :capitalize
|
116
122
|
r.capitalize
|
117
123
|
when :word
|
data/doc/ChangeLog
CHANGED
@@ -3,7 +3,17 @@
|
|
3
3
|
|
4
4
|
=== Renamer 0.5.0
|
5
5
|
|
6
|
-
2006-
|
6
|
+
2006-05-17 Nicolas Cavigneaux <nico@bounga.org>
|
7
|
+
|
8
|
+
* Corrected bug with constants in Rakefile
|
9
|
+
* Added methods to lowercase/uppercase extensions only
|
10
|
+
* Added Unit Tests
|
11
|
+
* Updated documentation
|
12
|
+
* Updated POT file
|
13
|
+
* Updated french translation
|
14
|
+
* Updated Renamer version constant
|
15
|
+
|
16
|
+
2006-04-27 Nicolas Cavigneaux <nico@bounga.org>
|
7
17
|
|
8
18
|
* Added overwrite mode
|
9
19
|
* Added Unit Tests
|
data/doc/TODO
CHANGED
data/doc/renamer
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Renamer - The perfect tool to easily rename your files
|
2
2
|
|
3
|
-
<b>Documentation for Renamer v0.4</b>
|
3
|
+
<b>Documentation for Renamer v0.4.3</b>
|
4
4
|
|
5
5
|
<em>Last Modified: 2006-01-07</em>
|
6
6
|
|
@@ -21,6 +21,8 @@ Its main features are :
|
|
21
21
|
* delete white-spaces from filenames
|
22
22
|
* capitalize filenames
|
23
23
|
* capitalize each words in filenames
|
24
|
+
* lowercase filename extensions
|
25
|
+
* uppercase filename extensions
|
24
26
|
* delete spaces in filenames
|
25
27
|
* replace underscores by spaces in filenames
|
26
28
|
* rename filenames using the specified basename followed by an incremental number
|
@@ -79,6 +81,8 @@ Available options for Renamer are:
|
|
79
81
|
* -u, --upcase : Upcase filenames
|
80
82
|
* -c, --capitalize : Capitalize filenames
|
81
83
|
* -w, --word : Capitalize each words in filenames
|
84
|
+
* --downcase_ext : Downcase filename extensions
|
85
|
+
* --upcase_ext : Upcase filename extensions
|
82
86
|
* -s, --space : Delete spaces in filenames
|
83
87
|
* -U, --underscore : Replace underscores by spaces in filenames
|
84
88
|
* -b, --basename : Rename filenames using the specified basename followed by an incremental number
|
data/lib/const.rb
CHANGED
data/lib/renamer.rb
CHANGED
@@ -71,6 +71,48 @@ class Renamer
|
|
71
71
|
run(proc_uc)
|
72
72
|
end
|
73
73
|
|
74
|
+
# Downcase filename extensions
|
75
|
+
def downcase_ext
|
76
|
+
proc_dc_ext = Proc.new do |file|
|
77
|
+
# We don't want to process dotfiles
|
78
|
+
unless File.basename(file) =~ /^\./
|
79
|
+
# We want to grep the last extension
|
80
|
+
name = file.split('.')
|
81
|
+
if name.size > 1 # Ensure that there's an extension
|
82
|
+
# Now we downcase it
|
83
|
+
ext = name.last.downcase
|
84
|
+
# Building the new name
|
85
|
+
name = name[0...-1].join(".")
|
86
|
+
new = name + '.' + ext
|
87
|
+
# Renaming
|
88
|
+
rename_fs(file, new)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
run(proc_dc_ext)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Upcase filename extensions
|
96
|
+
def upcase_ext
|
97
|
+
proc_uc_ext = Proc.new do |file|
|
98
|
+
# We don't want to process dotfiles
|
99
|
+
unless File.basename(file) =~ /^\./
|
100
|
+
# We want to grep the last extension
|
101
|
+
name = file.split('.')
|
102
|
+
if name.size > 1 # Ensure that there's an extension
|
103
|
+
# Now we upcase it
|
104
|
+
ext = name.last.upcase
|
105
|
+
# Building the new name
|
106
|
+
name = name[0...-1].join(".")
|
107
|
+
new = name + '.' + ext
|
108
|
+
# Renaming
|
109
|
+
rename_fs(file, new)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
run(proc_uc_ext)
|
114
|
+
end
|
115
|
+
|
74
116
|
# Replace spaces in filenames by underscores
|
75
117
|
def space_to_underscore
|
76
118
|
proc_s2u = Proc.new do |file|
|
data/po/fr/renamer.po
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
9
|
"Project-Id-Version: renamer\n"
|
10
|
-
"POT-Creation-Date: 2006-
|
11
|
-
"PO-Revision-Date: 2006-
|
10
|
+
"POT-Creation-Date: 2006-05-17 15:52+0200\n"
|
11
|
+
"PO-Revision-Date: 2006-05-17 15:54+0200\n"
|
12
12
|
"Last-Translator: Nicolas Cavigneaux <nico@bounga.org>\n"
|
13
13
|
"Language-Team: Français <fr@li.org>\n"
|
14
14
|
"MIME-Version: 1.0\n"
|
@@ -42,74 +42,82 @@ msgid "Capitalize each words in FILENAMES"
|
|
42
42
|
msgstr "Capitalise chaque mot dans FICHIERS"
|
43
43
|
|
44
44
|
#: bin/renamer:81
|
45
|
+
msgid "Downcase FILENAMES extensions"
|
46
|
+
msgstr "Mettre l'extension de FICHIERS en minuscules"
|
47
|
+
|
48
|
+
#: bin/renamer:82
|
49
|
+
msgid "Upcase FILENAMES extensions"
|
50
|
+
msgstr "Mettre l'extension de FICHIERS en majuscules"
|
51
|
+
|
52
|
+
#: bin/renamer:83
|
45
53
|
msgid "Replace spaces by underscores in FILENAMES"
|
46
54
|
msgstr "Transforme les espaces dans FICHIERS par des blancs soulignés"
|
47
55
|
|
48
|
-
#: bin/renamer:
|
56
|
+
#: bin/renamer:84
|
49
57
|
msgid "Replace underscores by spaces in FILENAMES"
|
50
58
|
msgstr "Remplace les blancs soulignés par des espaces dans FICHIERS "
|
51
59
|
|
52
|
-
#: bin/renamer:
|
60
|
+
#: bin/renamer:85
|
53
61
|
msgid "--basename BASENAME"
|
54
62
|
msgstr "--basename NOM_DE_BASE"
|
55
63
|
|
56
|
-
#: bin/renamer:
|
64
|
+
#: bin/renamer:85
|
57
65
|
msgid "Rename FILENAMES using the specified"
|
58
66
|
msgstr "Renomme FICHIERS. en utilisant le"
|
59
67
|
|
60
|
-
#: bin/renamer:
|
68
|
+
#: bin/renamer:85
|
61
69
|
msgid "BASENAME followed by an incremental number"
|
62
70
|
msgstr "NOM_DE_BASE spécifié suivit d'un nombre incrémental"
|
63
71
|
|
64
|
-
#: bin/renamer:
|
72
|
+
#: bin/renamer:86
|
65
73
|
msgid "--ext NEW"
|
66
74
|
msgstr "--ext NOUVELLE"
|
67
75
|
|
68
|
-
#: bin/renamer:
|
76
|
+
#: bin/renamer:86
|
69
77
|
msgid "Rename FILENAMES from their actual extension"
|
70
78
|
msgstr "Renomme FICHIERS de leur extension actuelle"
|
71
79
|
|
72
|
-
#: bin/renamer:
|
80
|
+
#: bin/renamer:86
|
73
81
|
msgid "to the NEW one"
|
74
82
|
msgstr "à la NOUVELLE"
|
75
83
|
|
76
|
-
#: bin/renamer:
|
84
|
+
#: bin/renamer:87
|
77
85
|
msgid "Run %s recursively across directories"
|
78
86
|
msgstr "Éxécute %s récurisivement à travers les répertoires"
|
79
87
|
|
80
|
-
#: bin/renamer:
|
88
|
+
#: bin/renamer:88
|
81
89
|
msgid "Overwrite existing files if needed"
|
82
90
|
msgstr "Écrase les fichiers existants si nécessaire"
|
83
91
|
|
84
|
-
#: bin/renamer:
|
85
|
-
msgid "Run %s in verbose mode (quiet by default)"
|
86
|
-
msgstr "Éxécute %s en mode verbeux (silencieux par défaut) "
|
87
|
-
|
88
|
-
#: bin/renamer:90
|
92
|
+
#: bin/renamer:91
|
89
93
|
msgid "Common options:"
|
90
94
|
msgstr "Options habituelles"
|
91
95
|
|
92
|
-
#: bin/renamer:
|
96
|
+
#: bin/renamer:93
|
93
97
|
msgid "Show this help"
|
94
98
|
msgstr "Affiche cette aide"
|
95
99
|
|
96
|
-
#: bin/renamer:
|
100
|
+
#: bin/renamer:94
|
97
101
|
msgid "Show %s version"
|
98
102
|
msgstr "Affiche la version de %s"
|
99
103
|
|
100
|
-
#: bin/renamer:
|
104
|
+
#: bin/renamer:95
|
101
105
|
msgid "Show some information about %s license"
|
102
106
|
msgstr "Affiche quelques informations à propos de la licence de %s"
|
103
107
|
|
108
|
+
#: bin/renamer:96
|
109
|
+
msgid "Run %s in verbose mode (quiet by default)"
|
110
|
+
msgstr "Éxécute %s en mode verbeux (silencieux par défaut) "
|
111
|
+
|
104
112
|
#: lib/renamer.rb:30
|
105
113
|
msgid "%s: %s file already exists!"
|
106
114
|
msgstr "%s : Le fichier %s existe déjà !"
|
107
115
|
|
108
|
-
#: lib/renamer.rb:
|
116
|
+
#: lib/renamer.rb:207
|
109
117
|
msgid "%s: You don't have write access on %s"
|
110
118
|
msgstr "%s : Vous n'avez pas les droits en écriture sur %s"
|
111
119
|
|
112
|
-
#: lib/renamer.rb:
|
120
|
+
#: lib/renamer.rb:210
|
113
121
|
msgid "%s: File %s doesn't exists!"
|
114
122
|
msgstr "%s : Le fichier %s n'existe pas !"
|
115
123
|
|
data/po/renamer.pot
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
#, fuzzy
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
|
-
"Project-Id-Version: 0.4.
|
10
|
-
"POT-Creation-Date: 2006-
|
9
|
+
"Project-Id-Version: 0.4.3\n"
|
10
|
+
"POT-Creation-Date: 2006-05-17 15:52+0200\n"
|
11
11
|
"PO-Revision-Date: 2005-12-16 21:30+0100\n"
|
12
12
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13
13
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
@@ -41,73 +41,81 @@ msgid "Capitalize each words in FILENAMES"
|
|
41
41
|
msgstr ""
|
42
42
|
|
43
43
|
#: bin/renamer:81
|
44
|
-
msgid "
|
44
|
+
msgid "Downcase FILENAMES extensions"
|
45
45
|
msgstr ""
|
46
46
|
|
47
47
|
#: bin/renamer:82
|
48
|
-
msgid "
|
48
|
+
msgid "Upcase FILENAMES extensions"
|
49
49
|
msgstr ""
|
50
50
|
|
51
51
|
#: bin/renamer:83
|
52
|
+
msgid "Replace spaces by underscores in FILENAMES"
|
53
|
+
msgstr ""
|
54
|
+
|
55
|
+
#: bin/renamer:84
|
56
|
+
msgid "Replace underscores by spaces in FILENAMES"
|
57
|
+
msgstr ""
|
58
|
+
|
59
|
+
#: bin/renamer:85
|
52
60
|
msgid "--basename BASENAME"
|
53
61
|
msgstr ""
|
54
62
|
|
55
|
-
#: bin/renamer:
|
63
|
+
#: bin/renamer:85
|
56
64
|
msgid "Rename FILENAMES using the specified"
|
57
65
|
msgstr ""
|
58
66
|
|
59
|
-
#: bin/renamer:
|
67
|
+
#: bin/renamer:85
|
60
68
|
msgid "BASENAME followed by an incremental number"
|
61
69
|
msgstr ""
|
62
70
|
|
63
|
-
#: bin/renamer:
|
71
|
+
#: bin/renamer:86
|
64
72
|
msgid "--ext NEW"
|
65
73
|
msgstr ""
|
66
74
|
|
67
|
-
#: bin/renamer:
|
75
|
+
#: bin/renamer:86
|
68
76
|
msgid "Rename FILENAMES from their actual extension"
|
69
77
|
msgstr ""
|
70
78
|
|
71
|
-
#: bin/renamer:
|
79
|
+
#: bin/renamer:86
|
72
80
|
msgid "to the NEW one"
|
73
81
|
msgstr ""
|
74
82
|
|
75
|
-
#: bin/renamer:
|
83
|
+
#: bin/renamer:87
|
76
84
|
msgid "Run %s recursively across directories"
|
77
85
|
msgstr ""
|
78
86
|
|
79
|
-
#: bin/renamer:
|
87
|
+
#: bin/renamer:88
|
80
88
|
msgid "Overwrite existing files if needed"
|
81
89
|
msgstr ""
|
82
90
|
|
83
|
-
#: bin/renamer:
|
84
|
-
msgid "Run %s in verbose mode (quiet by default)"
|
85
|
-
msgstr ""
|
86
|
-
|
87
|
-
#: bin/renamer:90
|
91
|
+
#: bin/renamer:91
|
88
92
|
msgid "Common options:"
|
89
93
|
msgstr ""
|
90
94
|
|
91
|
-
#: bin/renamer:
|
95
|
+
#: bin/renamer:93
|
92
96
|
msgid "Show this help"
|
93
97
|
msgstr ""
|
94
98
|
|
95
|
-
#: bin/renamer:
|
99
|
+
#: bin/renamer:94
|
96
100
|
msgid "Show %s version"
|
97
101
|
msgstr ""
|
98
102
|
|
99
|
-
#: bin/renamer:
|
103
|
+
#: bin/renamer:95
|
100
104
|
msgid "Show some information about %s license"
|
101
105
|
msgstr ""
|
102
106
|
|
107
|
+
#: bin/renamer:96
|
108
|
+
msgid "Run %s in verbose mode (quiet by default)"
|
109
|
+
msgstr ""
|
110
|
+
|
103
111
|
#: lib/renamer.rb:30
|
104
112
|
msgid "%s: %s file already exists!"
|
105
113
|
msgstr ""
|
106
114
|
|
107
|
-
#: lib/renamer.rb:
|
115
|
+
#: lib/renamer.rb:207
|
108
116
|
msgid "%s: You don't have write access on %s"
|
109
117
|
msgstr ""
|
110
118
|
|
111
|
-
#: lib/renamer.rb:
|
119
|
+
#: lib/renamer.rb:210
|
112
120
|
msgid "%s: File %s doesn't exists!"
|
113
121
|
msgstr ""
|
data/test/tc_renamer.rb
CHANGED
@@ -280,4 +280,56 @@ class TestRenamer < Test::Unit::TestCase
|
|
280
280
|
assert_nothing_raised(Errno::ENOENT) { File.open(".dotfile") }
|
281
281
|
assert_nothing_raised(Errno::ENOENT) { File.open("tmp_files2/.dotfile") }
|
282
282
|
end
|
283
|
+
|
284
|
+
def test_downcase_ext
|
285
|
+
@files << File.new("plop_plop", "w").path
|
286
|
+
@files << File.new("PLOP.txt", "w").path
|
287
|
+
@files << File.new("Plop.AvI", "w").path
|
288
|
+
@files << File.new("TesT_.Hop", "w").path
|
289
|
+
@files << File.new("test test.TXT", "w").path
|
290
|
+
@files << File.new("test test_test.TXT", "w").path
|
291
|
+
@files << File.new("teST.jpg.TXT", "w").path
|
292
|
+
@files << File.new(".DotFile", "w").path
|
293
|
+
Dir.mkdir("tmp_files2")
|
294
|
+
@files << File.new("tmp_files2/.DotFile", "w").path
|
295
|
+
|
296
|
+
r = Renamer.new(@files)
|
297
|
+
r.downcase_ext
|
298
|
+
|
299
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("plop_plop") }
|
300
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("PLOP.txt") }
|
301
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("Plop.avi") }
|
302
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("TesT_.hop") }
|
303
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("test test.txt") }
|
304
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("test test_test.txt") }
|
305
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("teST.jpg.txt") }
|
306
|
+
assert_nothing_raised(Errno::ENOENT) { File.open(".DotFile") }
|
307
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("tmp_files2/.DotFile") }
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_upcase_ext
|
311
|
+
@files << File.new("plop_plop", "w").path
|
312
|
+
@files << File.new("PLOP.txt", "w").path
|
313
|
+
@files << File.new("Plop.AvI", "w").path
|
314
|
+
@files << File.new("TesT_.Hop", "w").path
|
315
|
+
@files << File.new("test test.TXT", "w").path
|
316
|
+
@files << File.new("test test_test.TXT", "w").path
|
317
|
+
@files << File.new("teST.jpg.TXT", "w").path
|
318
|
+
@files << File.new(".DotFile", "w").path
|
319
|
+
Dir.mkdir("tmp_files2")
|
320
|
+
@files << File.new("tmp_files2/.DotFile", "w").path
|
321
|
+
|
322
|
+
r = Renamer.new(@files)
|
323
|
+
r.upcase_ext
|
324
|
+
|
325
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("plop_plop") }
|
326
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("PLOP.TXT") }
|
327
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("Plop.AVI") }
|
328
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("TesT_.HOP") }
|
329
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("test test.TXT") }
|
330
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("test test_test.TXT") }
|
331
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("teST.jpg.TXT") }
|
332
|
+
assert_nothing_raised(Errno::ENOENT) { File.open(".DotFile") }
|
333
|
+
assert_nothing_raised(Errno::ENOENT) { File.open("tmp_files2/.DotFile") }
|
334
|
+
end
|
283
335
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: Renamer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.4.
|
7
|
-
date: 2006-05-
|
6
|
+
version: 0.4.3
|
7
|
+
date: 2006-05-17 00:00:00 +02:00
|
8
8
|
summary: A fast and light utility to massively rename your files
|
9
9
|
require_paths:
|
10
10
|
- lib
|