Renamer 0.5.0 → 0.5.1
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/README.rdoc +5 -0
- data/bin/renamer +24 -12
- data/doc/BUGS.rdoc +2 -1
- data/doc/ChangeLog.rdoc +3 -1
- data/doc/FAQ.rdoc +5 -14
- data/doc/HACKING.rdoc +2 -2
- data/doc/TODO.rdoc +2 -5
- data/doc/renamer.rdoc +7 -3
- data/lib/const.rb +1 -1
- data/lib/renamer.rb +58 -0
- data/po/fr/renamer.po +34 -17
- data/po/renamer.pot +32 -16
- data/test/{tc_renamer.rb → tc_renamer_procs.rb} +141 -106
- data/test/ts_renamer.rb +17 -1
- metadata +8 -7
data/README.rdoc
CHANGED
@@ -42,3 +42,8 @@ See the COPYING file for more information.
|
|
42
42
|
|
43
43
|
Renamer (c) Copyright 2004-2008
|
44
44
|
by Nicolas Cavigneaux <nico@bounga.org>
|
45
|
+
|
46
|
+
=== Other
|
47
|
+
More information on project homepage (http://www.bitbucket.org/Bounga/renamer)
|
48
|
+
|
49
|
+
Comments, suggestions, patches are welcome on the ticket system (http://www.bitbucket.org/Bounga/renamer/issues/new/)
|
data/bin/renamer
CHANGED
@@ -82,17 +82,21 @@ opts.on("--downcase_ext", _("Downcase FILENAMES extensions")) { action = :downca
|
|
82
82
|
opts.on("--upcase_ext", _("Upcase FILENAMES extensions")) { action = :upcase_ext }
|
83
83
|
opts.on("-s", "--space", _("Replace spaces by underscores in FILENAMES")) { action = :space }
|
84
84
|
opts.on("-U", "--underscore", _("Replace underscores by spaces in FILENAMES")) { action = :underscore }
|
85
|
+
opts.on("--date", _("Add current date to the beginning of FILENAMES")) { action = :date }
|
86
|
+
opts.on("--datetime", _("Add current datetime to the beginning of FILENAMES")) { action = :datetime }
|
85
87
|
opts.on("-b", _("--basename BASENAME"), _("Rename FILENAMES using the specified"), _("BASENAME followed by an incremental number")) { |bn| action = :basename; arg = bn }
|
86
88
|
opts.on("-e", _("--ext NEW"), _("Rename FILENAMES from their actual extension"), _("to the NEW one")) { |new| action = :ext; arg = new }
|
89
|
+
opts.on("-f", "--trim-first n", _("Rename FILENAMES by trimming first n characters")) { |n| action = :trim_first; arg = n }
|
90
|
+
opts.on("-l", "--trim-last n", _("Rename FILENAMES by trimming last n characters"), _("to the NEW one")) { |n| action = :trim_last; arg = n }
|
87
91
|
opts.on("-r", "--recursive", _("Run %s recursively across directories") % Const::NAME) { recursive = true }
|
88
92
|
opts.on("-o", "--overwrite", _("Overwrite existing files if needed") % Const::NAME) { overwrite = true }
|
89
93
|
|
90
94
|
opts.separator ""
|
91
95
|
opts.separator _("Common options:")
|
92
96
|
|
93
|
-
opts.
|
97
|
+
opts.on_tail("-h", "--help", _("Show this help")) { puts opts.to_s; exit(0) }
|
94
98
|
opts.on("-v", "--version", _("Show %s version") % Const::NAME) { puts Const::NAME + " v" + Const::VER; exit(0) }
|
95
|
-
opts.on("-
|
99
|
+
opts.on("-L", "--license", _("Show some information about %s license") % Const::NAME) { puts Const::LICENSE; exit(0) }
|
96
100
|
opts.on("-V", "--verbose", _("Run %s in verbose mode (quiet by default)") % Const::NAME) { $VERBOSE = true }
|
97
101
|
|
98
102
|
###################
|
@@ -111,23 +115,31 @@ r = Renamer.new(filenames, recursive, overwrite)
|
|
111
115
|
|
112
116
|
case action
|
113
117
|
when :downcase
|
114
|
-
|
118
|
+
r.downcase
|
115
119
|
when :upcase
|
116
|
-
|
120
|
+
r.upcase
|
117
121
|
when :downcase_ext
|
118
|
-
|
122
|
+
r.downcase_ext
|
119
123
|
when :upcase_ext
|
120
|
-
|
124
|
+
r.upcase_ext
|
121
125
|
when :capitalize
|
122
|
-
|
126
|
+
r.capitalize
|
123
127
|
when :word
|
124
|
-
|
128
|
+
r.capitalize_words
|
125
129
|
when :space
|
126
|
-
|
130
|
+
r.space_to_underscore
|
127
131
|
when :underscore
|
128
|
-
|
132
|
+
r.underscore_to_space
|
129
133
|
when :basename
|
130
|
-
|
134
|
+
r.basename(arg)
|
131
135
|
when :ext
|
132
|
-
|
136
|
+
r.ext(arg)
|
137
|
+
when :trim_first
|
138
|
+
r.trim_first(arg)
|
139
|
+
when :trim_last
|
140
|
+
r.trim_last(arg)
|
141
|
+
when :date
|
142
|
+
r.current_date(Time.now)
|
143
|
+
when :datetime
|
144
|
+
r.current_datetime(Time.now)
|
133
145
|
end
|
data/doc/BUGS.rdoc
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
= Renamer - The perfect tool to easily rename your files
|
2
2
|
|
3
3
|
== Known bugs:
|
4
|
-
Last Modified:
|
4
|
+
Last Modified: 2008-10-30
|
5
5
|
|
6
6
|
* Using of wildcards on the command-line only works for unix shells we must use Dir[] if we want this feature to be available on other systems (MS-Windows for example).
|
7
|
+
* Test test_mv fails
|
data/doc/ChangeLog.rdoc
CHANGED
@@ -3,11 +3,13 @@
|
|
3
3
|
|
4
4
|
=== Renamer 0.5.0
|
5
5
|
|
6
|
-
2008-10-
|
6
|
+
2008-10-30 Nicolas Cavigneaux <nico@bounga.org>
|
7
7
|
|
8
8
|
* Improved Rakefile
|
9
9
|
* Now explicitly use RDoc format for documentation
|
10
10
|
* Updated infos
|
11
|
+
* Added current date/time renaming
|
12
|
+
* Added renaming by delete the "n" first/last characters
|
11
13
|
|
12
14
|
=== Renamer 0.4.4
|
13
15
|
|
data/doc/FAQ.rdoc
CHANGED
@@ -56,24 +56,15 @@ It will show you some help about the possible options and how to use them.
|
|
56
56
|
|
57
57
|
=== 3.1. How should I report bugs?
|
58
58
|
|
59
|
-
You
|
60
|
-
* You can submit your bug at this url: http://rubyforge.org/tracker/?func=browse&group_id=1450&atid=5661
|
61
|
-
* You can join us on IRC: <em>irc.freenode.net</em>, and try to contact a developer. If no one can help you (huh?), try another way.
|
62
|
-
* You can mail your problem to a developer. Look at the support page for developer's mails: http://rubyforge.org/project/memberlist.php?group_id=1450
|
59
|
+
You can submit your bug at http://bounga.lighthouseapp.com/projects/18642-renamer/tickets/new with <em>bug</em> tag
|
63
60
|
|
64
61
|
=== 3.2. How should I submit patches?
|
65
62
|
|
66
|
-
|
67
|
-
* You can submit your patch at this url: http://rubyforge.org/tracker/?atid=5663&group_id=1450&func=browse
|
68
|
-
* You can join us on IRC: <em>irc.freenode.net</em>, and try to contact a developer. If no one can help you (huh?), try another way.
|
69
|
-
* You can mail your patch, look at support page for developer's mails: http://rubyforge.org/project/memberlist.php?group_id=1450
|
63
|
+
You can submit your patch at http://bounga.lighthouseapp.com/projects/18642-renamer/tickets/new with <em>patch</em> tag
|
70
64
|
|
71
65
|
=== 3.3. How should I submit new feature request?
|
72
66
|
|
73
|
-
|
74
|
-
* You can join us on IRC: <em>irc.freenode.net</em>, and try to contact a developer. If no one can help you (huh?), try another way.
|
75
|
-
* You can submit your request at this url: http://rubyforge.org/tracker/?atid=5664&group_id=1450&func=browse
|
76
|
-
* You can mail your feature request, look at support page for developer's mails: http://rubyforge.org/project/memberlist.php?group_id=1450
|
67
|
+
You can submit your request at http://bounga.lighthouseapp.com/projects/18642-renamer/tickets/new with <em>feature</em> tag
|
77
68
|
|
78
69
|
=== 3.4. Will Renamer be ported to *BSD, QNX, MacOS X, Microsoft Windows ?
|
79
70
|
|
@@ -85,8 +76,8 @@ Unix-like OS so it's was not tested on Microsoft Windows.
|
|
85
76
|
=== 3.5. I want to help Renamer developers. What can I do?
|
86
77
|
|
87
78
|
There's many tasks to do (code, documentation, ...). Please contact us
|
88
|
-
using IRC or e-mail, and look at this page: http://
|
89
|
-
It lists all the
|
79
|
+
using IRC or e-mail, and look at this page: http://bounga.lighthouseapp.com/projects/18642-renamer/tickets?q=state%3Aopen
|
80
|
+
It lists all the open tasks. You can also look at the TODO and BUGS files
|
90
81
|
available in the package.
|
91
82
|
|
92
83
|
=== 3.6. Can I give money or other things to Renamer developers?
|
data/doc/HACKING.rdoc
CHANGED
@@ -16,7 +16,7 @@ need to stick to in order to get your patches accepted.
|
|
16
16
|
It can be a little annoying to change your coding style if you're used to something else, but we need to use only one style
|
17
17
|
to allow people to read the code and understand it easily.
|
18
18
|
|
19
|
-
* Use
|
19
|
+
* Use 2-space tabs for indentation and expand tabs to spaces (if you use VIM, <tt>set ts=2</tt> and <tt>set et</tt>). Don't use tabs at all.
|
20
20
|
* Join words of class names by capitalizing the first letter of each word (CamelCase)
|
21
21
|
* Join words of method names and variables with underscores
|
22
22
|
* Constants should always be in uppercase and should have words separated by undescores
|
@@ -34,4 +34,4 @@ to allow people to read the code and understand it easily.
|
|
34
34
|
* Always provide patches in unified form (diff -u) and with a ChangeLog entry
|
35
35
|
* Always provide Unit Test for all the functionnalities you've added
|
36
36
|
|
37
|
-
If you think that your patch sticks these requirements you can send
|
37
|
+
If you think that your patch sticks these requirements you can send at http://bounga.lighthouseapp.com/projects/18642-renamer/tickets/new with <em>patch</em> tag
|
data/doc/TODO.rdoc
CHANGED
@@ -2,15 +2,12 @@
|
|
2
2
|
|
3
3
|
== To Do List
|
4
4
|
|
5
|
-
Send suggestions for this list
|
6
|
-
http://
|
5
|
+
Send suggestions for this list on
|
6
|
+
http://bounga.lighthouseapp.com/projects/18642-renamer/tickets/new with <em>feature</em> tag.
|
7
7
|
|
8
8
|
|
9
9
|
=== Before next release
|
10
10
|
|
11
|
-
* Add a method to rename files using current date/time
|
12
|
-
* Add a method to delete the "n" first/last characters
|
13
|
-
|
14
11
|
=== Future releases
|
15
12
|
|
16
13
|
* Any idea ? Feel free to contact developers
|
data/doc/renamer.rdoc
CHANGED
@@ -80,14 +80,18 @@ Available options for Renamer are:
|
|
80
80
|
* --upcase_ext : Upcase filename extensions
|
81
81
|
* -s, --space : Delete spaces in filenames
|
82
82
|
* -U, --underscore : Replace underscores by spaces in filenames
|
83
|
-
*
|
84
|
-
*
|
83
|
+
* --date : Add current date to the beginning of filenames
|
84
|
+
* --datetime : Add current datetime to the beginning of filenames
|
85
|
+
* -b, --basename : Rename file using the specified basename followed by an incremental number
|
86
|
+
* -e, --ext : Rename file from their actual extension to the specified one
|
87
|
+
* -f, --trim-first : Rename file by trimming first n characters
|
88
|
+
* -l, --trim-last : Rename file by trimming last n characters
|
85
89
|
* -r, --recursive : Run Renamer recursively across directories
|
86
90
|
* -o, --overwrite : Overwrite existing files if needed
|
87
91
|
* -V, --verbose : Run Renamer in verbose mode (quiet by default)
|
88
92
|
* -h, --help : Show some help
|
89
93
|
* -v, --version : Show Renamer version
|
90
|
-
* -
|
94
|
+
* -L, --license : Show some information about Renamer license
|
91
95
|
|
92
96
|
== Authors / Support
|
93
97
|
|
data/lib/const.rb
CHANGED
data/lib/renamer.rb
CHANGED
@@ -195,6 +195,64 @@ class Renamer
|
|
195
195
|
end
|
196
196
|
run(proc_ext, e)
|
197
197
|
end
|
198
|
+
|
199
|
+
# Trim first n characters
|
200
|
+
def trim_first(n)
|
201
|
+
proc_trim_first = Proc.new do |file, n|
|
202
|
+
# Grabbing name and ext
|
203
|
+
elements = file.split(".")
|
204
|
+
if elements.size < 2
|
205
|
+
name = elements.first
|
206
|
+
ext = nil
|
207
|
+
else
|
208
|
+
name = elements[0...-1].join('.')
|
209
|
+
ext = elements[-1, 1].first
|
210
|
+
end
|
211
|
+
|
212
|
+
# trimming the n first characters
|
213
|
+
new = [name[n..-1], ext].compact.join('.')
|
214
|
+
rename(file, new)
|
215
|
+
end
|
216
|
+
run(proc_trim_first, n)
|
217
|
+
end
|
218
|
+
|
219
|
+
# Trim last n characters
|
220
|
+
def trim_last(n)
|
221
|
+
proc_trim_last = Proc.new do |file, n|
|
222
|
+
# Grabbing name and ext
|
223
|
+
elements = file.split(".")
|
224
|
+
if elements.size < 2
|
225
|
+
name = elements.first
|
226
|
+
ext = nil
|
227
|
+
else
|
228
|
+
name = elements[0...-1].join('.')
|
229
|
+
ext = elements[-1, 1].first
|
230
|
+
end
|
231
|
+
|
232
|
+
# trimming the n last characters
|
233
|
+
new = [name[0, name.length - n], ext].compact.join('.')
|
234
|
+
rename(file, new)
|
235
|
+
end
|
236
|
+
run(proc_trim_last, n)
|
237
|
+
end
|
238
|
+
|
239
|
+
# Add date (using time arg) to the beginning of the filename
|
240
|
+
def current_date(time)
|
241
|
+
proc_current_date = Proc.new do |file, date|
|
242
|
+
new = [date, file].join('_')
|
243
|
+
rename(file, new)
|
244
|
+
end
|
245
|
+
run(proc_current_date, time.strftime("%Y-%m-%d"))
|
246
|
+
end
|
247
|
+
|
248
|
+
# Add datetime (using time arg) to the beginning of the filename
|
249
|
+
def current_datetime(datetime)
|
250
|
+
proc_current_datetime = Proc.new do |file, datetime|
|
251
|
+
new = [datetime, file].join('_')
|
252
|
+
rename(file, new)
|
253
|
+
end
|
254
|
+
run(proc_current_datetime, datetime.strftime("%Y-%m-%d_%H-%M"))
|
255
|
+
end
|
198
256
|
|
199
257
|
private
|
200
258
|
# Helper to test files and run the specific job
|
data/po/fr/renamer.po
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
# Nicolas Cavigneaux <nico@bounga.org>, 2005, 2006.
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
|
-
"Project-Id-Version:
|
10
|
-
"POT-Creation-Date:
|
9
|
+
"Project-Id-Version: 0.5.0\n"
|
10
|
+
"POT-Creation-Date: 2008-10-27 20:48+0100\n"
|
11
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"
|
@@ -58,54 +58,72 @@ msgid "Replace underscores by spaces in FILENAMES"
|
|
58
58
|
msgstr "Remplace les blancs soulignés par des espaces dans FICHIERS "
|
59
59
|
|
60
60
|
#: bin/renamer:85
|
61
|
+
msgid "Add current date to the beginning of FILENAMES"
|
62
|
+
msgstr "Ajouter la date courante en début de FICHIERS"
|
63
|
+
|
64
|
+
#: bin/renamer:86
|
65
|
+
msgid "Add current datetime to the beginning of FILENAMES"
|
66
|
+
msgstr "Ajouter la date et l'heure courante en début de FICHIERS"
|
67
|
+
|
68
|
+
#: bin/renamer:87
|
61
69
|
msgid "--basename BASENAME"
|
62
70
|
msgstr "--basename NOM_DE_BASE"
|
63
71
|
|
64
|
-
#: bin/renamer:
|
72
|
+
#: bin/renamer:87
|
65
73
|
msgid "Rename FILENAMES using the specified"
|
66
74
|
msgstr "Renomme FICHIERS. en utilisant le"
|
67
75
|
|
68
|
-
#: bin/renamer:
|
76
|
+
#: bin/renamer:87
|
69
77
|
msgid "BASENAME followed by an incremental number"
|
70
78
|
msgstr "NOM_DE_BASE spécifié suivit d'un nombre incrémental"
|
71
79
|
|
72
|
-
#: bin/renamer:
|
80
|
+
#: bin/renamer:88
|
73
81
|
msgid "--ext NEW"
|
74
82
|
msgstr "--ext NOUVELLE"
|
75
83
|
|
76
|
-
#: bin/renamer:
|
84
|
+
#: bin/renamer:88
|
77
85
|
msgid "Rename FILENAMES from their actual extension"
|
78
86
|
msgstr "Renomme FICHIERS de leur extension actuelle"
|
79
87
|
|
80
|
-
#: bin/renamer:
|
88
|
+
#: bin/renamer:88 bin/renamer:90
|
81
89
|
msgid "to the NEW one"
|
82
90
|
msgstr "à la NOUVELLE"
|
83
91
|
|
84
|
-
#: bin/renamer:
|
92
|
+
#: bin/renamer:89
|
93
|
+
#, fuzzy
|
94
|
+
msgid "Rename FILENAMES by trimming first n characters"
|
95
|
+
msgstr "Renomme FICHIERS de leur extension actuelle"
|
96
|
+
|
97
|
+
#: bin/renamer:90
|
98
|
+
#, fuzzy
|
99
|
+
msgid "Rename FILENAMES by trimming last n characters"
|
100
|
+
msgstr "Renomme FICHIERS de leur extension actuelle"
|
101
|
+
|
102
|
+
#: bin/renamer:91
|
85
103
|
msgid "Run %s recursively across directories"
|
86
104
|
msgstr "Éxécute %s récurisivement à travers les répertoires"
|
87
105
|
|
88
|
-
#: bin/renamer:
|
106
|
+
#: bin/renamer:92
|
89
107
|
msgid "Overwrite existing files if needed"
|
90
108
|
msgstr "Écrase les fichiers existants si nécessaire"
|
91
109
|
|
92
|
-
#: bin/renamer:
|
110
|
+
#: bin/renamer:95
|
93
111
|
msgid "Common options:"
|
94
112
|
msgstr "Options habituelles"
|
95
113
|
|
96
|
-
#: bin/renamer:
|
114
|
+
#: bin/renamer:97
|
97
115
|
msgid "Show this help"
|
98
116
|
msgstr "Affiche cette aide"
|
99
117
|
|
100
|
-
#: bin/renamer:
|
118
|
+
#: bin/renamer:98
|
101
119
|
msgid "Show %s version"
|
102
120
|
msgstr "Affiche la version de %s"
|
103
121
|
|
104
|
-
#: bin/renamer:
|
122
|
+
#: bin/renamer:99
|
105
123
|
msgid "Show some information about %s license"
|
106
124
|
msgstr "Affiche quelques informations à propos de la licence de %s"
|
107
125
|
|
108
|
-
#: bin/renamer:
|
126
|
+
#: bin/renamer:100
|
109
127
|
msgid "Run %s in verbose mode (quiet by default)"
|
110
128
|
msgstr "Éxécute %s en mode verbeux (silencieux par défaut) "
|
111
129
|
|
@@ -113,11 +131,10 @@ msgstr "Éxécute %s en mode verbeux (silencieux par défaut) "
|
|
113
131
|
msgid "%s: %s file already exists!"
|
114
132
|
msgstr "%s : Le fichier %s existe déjà !"
|
115
133
|
|
116
|
-
#: lib/renamer.rb:
|
134
|
+
#: lib/renamer.rb:265
|
117
135
|
msgid "%s: You don't have write access on %s"
|
118
136
|
msgstr "%s : Vous n'avez pas les droits en écriture sur %s"
|
119
137
|
|
120
|
-
#: lib/renamer.rb:
|
138
|
+
#: lib/renamer.rb:268
|
121
139
|
msgid "%s: File %s doesn't exists!"
|
122
140
|
msgstr "%s : Le fichier %s n'existe pas !"
|
123
|
-
|
data/po/renamer.pot
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
#, fuzzy
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
|
-
"Project-Id-Version: 0.
|
10
|
-
"POT-Creation-Date:
|
9
|
+
"Project-Id-Version: 0.5.0\n"
|
10
|
+
"POT-Creation-Date: 2008-10-27 20:48+0100\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"
|
@@ -57,54 +57,70 @@ msgid "Replace underscores by spaces in FILENAMES"
|
|
57
57
|
msgstr ""
|
58
58
|
|
59
59
|
#: bin/renamer:85
|
60
|
+
msgid "Add current date to the beginning of FILENAMES"
|
61
|
+
msgstr ""
|
62
|
+
|
63
|
+
#: bin/renamer:86
|
64
|
+
msgid "Add current datetime to the beginning of FILENAMES"
|
65
|
+
msgstr ""
|
66
|
+
|
67
|
+
#: bin/renamer:87
|
60
68
|
msgid "--basename BASENAME"
|
61
69
|
msgstr ""
|
62
70
|
|
63
|
-
#: bin/renamer:
|
71
|
+
#: bin/renamer:87
|
64
72
|
msgid "Rename FILENAMES using the specified"
|
65
73
|
msgstr ""
|
66
74
|
|
67
|
-
#: bin/renamer:
|
75
|
+
#: bin/renamer:87
|
68
76
|
msgid "BASENAME followed by an incremental number"
|
69
77
|
msgstr ""
|
70
78
|
|
71
|
-
#: bin/renamer:
|
79
|
+
#: bin/renamer:88
|
72
80
|
msgid "--ext NEW"
|
73
81
|
msgstr ""
|
74
82
|
|
75
|
-
#: bin/renamer:
|
83
|
+
#: bin/renamer:88
|
76
84
|
msgid "Rename FILENAMES from their actual extension"
|
77
85
|
msgstr ""
|
78
86
|
|
79
|
-
#: bin/renamer:
|
87
|
+
#: bin/renamer:88 bin/renamer:90
|
80
88
|
msgid "to the NEW one"
|
81
89
|
msgstr ""
|
82
90
|
|
83
|
-
#: bin/renamer:
|
91
|
+
#: bin/renamer:89
|
92
|
+
msgid "Rename FILENAMES by trimming first n characters"
|
93
|
+
msgstr ""
|
94
|
+
|
95
|
+
#: bin/renamer:90
|
96
|
+
msgid "Rename FILENAMES by trimming last n characters"
|
97
|
+
msgstr ""
|
98
|
+
|
99
|
+
#: bin/renamer:91
|
84
100
|
msgid "Run %s recursively across directories"
|
85
101
|
msgstr ""
|
86
102
|
|
87
|
-
#: bin/renamer:
|
103
|
+
#: bin/renamer:92
|
88
104
|
msgid "Overwrite existing files if needed"
|
89
105
|
msgstr ""
|
90
106
|
|
91
|
-
#: bin/renamer:
|
107
|
+
#: bin/renamer:95
|
92
108
|
msgid "Common options:"
|
93
109
|
msgstr ""
|
94
110
|
|
95
|
-
#: bin/renamer:
|
111
|
+
#: bin/renamer:97
|
96
112
|
msgid "Show this help"
|
97
113
|
msgstr ""
|
98
114
|
|
99
|
-
#: bin/renamer:
|
115
|
+
#: bin/renamer:98
|
100
116
|
msgid "Show %s version"
|
101
117
|
msgstr ""
|
102
118
|
|
103
|
-
#: bin/renamer:
|
119
|
+
#: bin/renamer:99
|
104
120
|
msgid "Show some information about %s license"
|
105
121
|
msgstr ""
|
106
122
|
|
107
|
-
#: bin/renamer:
|
123
|
+
#: bin/renamer:100
|
108
124
|
msgid "Run %s in verbose mode (quiet by default)"
|
109
125
|
msgstr ""
|
110
126
|
|
@@ -112,10 +128,10 @@ msgstr ""
|
|
112
128
|
msgid "%s: %s file already exists!"
|
113
129
|
msgstr ""
|
114
130
|
|
115
|
-
#: lib/renamer.rb:
|
131
|
+
#: lib/renamer.rb:265
|
116
132
|
msgid "%s: You don't have write access on %s"
|
117
133
|
msgstr ""
|
118
134
|
|
119
|
-
#: lib/renamer.rb:
|
135
|
+
#: lib/renamer.rb:268
|
120
136
|
msgid "%s: File %s doesn't exists!"
|
121
137
|
msgstr ""
|
@@ -18,25 +18,8 @@
|
|
18
18
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
19
|
=end
|
20
20
|
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'rubygems'
|
24
|
-
rescue LoadError
|
25
|
-
warn "Not using RubyGems" if $DEBUG
|
26
|
-
end
|
27
|
-
|
28
|
-
$:.unshift(File.dirname(__FILE__) + "/../lib/")
|
29
|
-
|
30
|
-
require 'test/unit'
|
31
|
-
require 'rubygems'
|
32
|
-
require 'gettext'
|
33
|
-
require 'tempfile'
|
34
|
-
require 'fileutils'
|
35
|
-
require 'const'
|
36
|
-
require 'renamer'
|
37
|
-
|
38
|
-
# Testing
|
39
|
-
class TestRenamer < Test::Unit::TestCase
|
21
|
+
# Testing procs
|
22
|
+
class TestRenamerProcs < Test::Unit::TestCase
|
40
23
|
def setup
|
41
24
|
$VERBOSE = nil
|
42
25
|
@files = Array.new
|
@@ -44,7 +27,7 @@ class TestRenamer < Test::Unit::TestCase
|
|
44
27
|
Dir.chdir("tmp_files")
|
45
28
|
end
|
46
29
|
|
47
|
-
def teardown
|
30
|
+
def teardown
|
48
31
|
Dir.chdir("..")
|
49
32
|
FileUtils.rm_rf("tmp_files")
|
50
33
|
end
|
@@ -55,9 +38,9 @@ class TestRenamer < Test::Unit::TestCase
|
|
55
38
|
|
56
39
|
r = Renamer.new(@files)
|
57
40
|
r.downcase
|
58
|
-
|
59
|
-
|
60
|
-
|
41
|
+
|
42
|
+
assert(!File.exist?("PLOP"))
|
43
|
+
assert(!File.exist?("TesT.Hop"))
|
61
44
|
end
|
62
45
|
|
63
46
|
def test_subdirectory
|
@@ -69,8 +52,8 @@ class TestRenamer < Test::Unit::TestCase
|
|
69
52
|
r = Renamer.new(@files)
|
70
53
|
r.downcase
|
71
54
|
|
72
|
-
|
73
|
-
|
55
|
+
assert(File.exist?("test1/plop.txt"))
|
56
|
+
assert(File.exist?("test2/plop.txt"))
|
74
57
|
end
|
75
58
|
|
76
59
|
def test_recursivity
|
@@ -86,10 +69,10 @@ class TestRenamer < Test::Unit::TestCase
|
|
86
69
|
r = Renamer.new(@files, true)
|
87
70
|
r.downcase
|
88
71
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
72
|
+
assert(File.exist?("test1/plop.txt"))
|
73
|
+
assert(File.exist?("test1/test3/plop.txt"))
|
74
|
+
assert(File.exist?("test1/test3/test4/plop.txt"))
|
75
|
+
assert(File.exist?("test2/plop.txt"))
|
93
76
|
end
|
94
77
|
|
95
78
|
def test_overwrite
|
@@ -100,8 +83,8 @@ class TestRenamer < Test::Unit::TestCase
|
|
100
83
|
r = Renamer.new(@files, false, false)
|
101
84
|
r.underscore_to_space
|
102
85
|
|
103
|
-
|
104
|
-
|
86
|
+
assert(File.exist?("plop_plop"))
|
87
|
+
assert(File.exist?("plop plop"))
|
105
88
|
|
106
89
|
# Now we test that files are overwrited when overwrite is true
|
107
90
|
@files.clear
|
@@ -111,8 +94,8 @@ class TestRenamer < Test::Unit::TestCase
|
|
111
94
|
r = Renamer.new(@files, false, true)
|
112
95
|
r.underscore_to_space
|
113
96
|
|
114
|
-
|
115
|
-
|
97
|
+
assert(!File.exist?("test_test"))
|
98
|
+
assert(File.exist?("test test"))
|
116
99
|
end
|
117
100
|
|
118
101
|
def test_downcase
|
@@ -126,12 +109,12 @@ class TestRenamer < Test::Unit::TestCase
|
|
126
109
|
r = Renamer.new(@files)
|
127
110
|
r.downcase
|
128
111
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
112
|
+
assert(File.exist?("plop"))
|
113
|
+
assert(File.exist?("plop.txt"))
|
114
|
+
assert(File.exist?("plop.jpg"))
|
115
|
+
assert(File.exist?("test.hop"))
|
116
|
+
assert(File.exist?("test.txt"))
|
117
|
+
assert(File.exist?("test.jpg.txt"))
|
135
118
|
end
|
136
119
|
|
137
120
|
def test_upcase
|
@@ -144,13 +127,13 @@ class TestRenamer < Test::Unit::TestCase
|
|
144
127
|
|
145
128
|
r = Renamer.new(@files)
|
146
129
|
r.upcase
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
130
|
+
|
131
|
+
assert(File.exist?("PLOP"))
|
132
|
+
assert(File.exist?("PLOP.TXT"))
|
133
|
+
assert(File.exist?("PLOP.JPG"))
|
134
|
+
assert(File.exist?("TEST.HOP"))
|
135
|
+
assert(File.exist?("TEST.TXT"))
|
136
|
+
assert(File.exist?("TEST.JPG.TXT"))
|
154
137
|
end
|
155
138
|
|
156
139
|
def test_space_to_underscore
|
@@ -164,12 +147,12 @@ class TestRenamer < Test::Unit::TestCase
|
|
164
147
|
r = Renamer.new(@files)
|
165
148
|
r.space_to_underscore
|
166
149
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
150
|
+
assert(File.exist?("plop_plop"))
|
151
|
+
assert(File.exist?("PLOP.txt"))
|
152
|
+
assert(File.exist?("PLOP_PLOP_PLOP.avi"))
|
153
|
+
assert(File.exist?("TesT_.Hop"))
|
154
|
+
assert(File.exist?("test._txt"))
|
155
|
+
assert(File.exist?("teST.jpg.txt"))
|
173
156
|
end
|
174
157
|
|
175
158
|
def test_underscore_to_space
|
@@ -183,12 +166,12 @@ class TestRenamer < Test::Unit::TestCase
|
|
183
166
|
r = Renamer.new(@files)
|
184
167
|
r.underscore_to_space
|
185
168
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
169
|
+
assert(File.exist?("plop plop"))
|
170
|
+
assert(File.exist?("PLOP.txt"))
|
171
|
+
assert(File.exist?("PLOP PLOP PLOP.avi"))
|
172
|
+
assert(File.exist?("TesT .Hop"))
|
173
|
+
assert(File.exist?("test. txt"))
|
174
|
+
assert(File.exist?("teST.jpg.txt"))
|
192
175
|
end
|
193
176
|
|
194
177
|
def test_capitalize
|
@@ -202,12 +185,12 @@ class TestRenamer < Test::Unit::TestCase
|
|
202
185
|
r = Renamer.new(@files)
|
203
186
|
r.capitalize
|
204
187
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
188
|
+
assert(File.exist?("Plop_plop"))
|
189
|
+
assert(File.exist?("Plop.txt"))
|
190
|
+
assert(File.exist?("Plop.avi"))
|
191
|
+
assert(File.exist?("Test_.hop"))
|
192
|
+
assert(File.exist?("Test test.txt"))
|
193
|
+
assert(File.exist?("Test.jpg.txt"))
|
211
194
|
end
|
212
195
|
|
213
196
|
def test_capitalize_words
|
@@ -223,14 +206,14 @@ class TestRenamer < Test::Unit::TestCase
|
|
223
206
|
r = Renamer.new(@files)
|
224
207
|
r.capitalize_words
|
225
208
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
209
|
+
assert(File.exist?("Plop_Plop"))
|
210
|
+
assert(File.exist?("Plop.txt"))
|
211
|
+
assert(File.exist?("Plop.avi"))
|
212
|
+
assert(File.exist?("Test_.hop"))
|
213
|
+
assert(File.exist?("Test Test.txt"))
|
214
|
+
assert(File.exist?("Test Test_Test.txt"))
|
215
|
+
assert(File.exist?("Test.Jpg.txt"))
|
216
|
+
assert(File.exist?(".dotfile"))
|
234
217
|
end
|
235
218
|
|
236
219
|
def test_basename
|
@@ -246,13 +229,13 @@ class TestRenamer < Test::Unit::TestCase
|
|
246
229
|
r = Renamer.new(@files)
|
247
230
|
r.basename("test")
|
248
231
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
232
|
+
assert(File.exist?("test0000.txt"))
|
233
|
+
assert(File.exist?("test0001.txt"))
|
234
|
+
assert(File.exist?("test0002.txt"))
|
235
|
+
assert(File.exist?("test0003.txt"))
|
236
|
+
assert(File.exist?("test0005.txt"))
|
237
|
+
assert(File.exist?("test0006.txt"))
|
238
|
+
assert(File.exist?("test0000"))
|
256
239
|
end
|
257
240
|
|
258
241
|
def test_ext
|
@@ -270,15 +253,15 @@ class TestRenamer < Test::Unit::TestCase
|
|
270
253
|
r = Renamer.new(@files)
|
271
254
|
r.ext("rnm")
|
272
255
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
256
|
+
assert(File.exist?("plop_plop.rnm"))
|
257
|
+
assert(File.exist?("PLOP.rnm"))
|
258
|
+
assert(File.exist?("Plop.rnm"))
|
259
|
+
assert(File.exist?("TesT_.rnm"))
|
260
|
+
assert(File.exist?("test test.rnm"))
|
261
|
+
assert(File.exist?("test test_test.rnm"))
|
262
|
+
assert(File.exist?("teST.jpg.rnm"))
|
263
|
+
assert(File.exist?(".dotfile"))
|
264
|
+
assert(File.exist?("tmp_files2/.dotfile"))
|
282
265
|
end
|
283
266
|
|
284
267
|
def test_downcase_ext
|
@@ -296,15 +279,15 @@ class TestRenamer < Test::Unit::TestCase
|
|
296
279
|
r = Renamer.new(@files)
|
297
280
|
r.downcase_ext
|
298
281
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
282
|
+
assert(File.exist?("plop_plop"))
|
283
|
+
assert(File.exist?("PLOP.txt"))
|
284
|
+
assert(File.exist?("Plop.avi"))
|
285
|
+
assert(File.exist?("TesT_.hop"))
|
286
|
+
assert(File.exist?("test test.txt"))
|
287
|
+
assert(File.exist?("test test_test.txt"))
|
288
|
+
assert(File.exist?("teST.jpg.txt"))
|
289
|
+
assert(File.exist?(".DotFile"))
|
290
|
+
assert(File.exist?("tmp_files2/.DotFile"))
|
308
291
|
end
|
309
292
|
|
310
293
|
def test_upcase_ext
|
@@ -322,14 +305,66 @@ class TestRenamer < Test::Unit::TestCase
|
|
322
305
|
r = Renamer.new(@files)
|
323
306
|
r.upcase_ext
|
324
307
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
308
|
+
assert(File.exist?("plop_plop"))
|
309
|
+
assert(File.exist?("PLOP.TXT"))
|
310
|
+
assert(File.exist?("Plop.AVI"))
|
311
|
+
assert(File.exist?("TesT_.HOP"))
|
312
|
+
assert(File.exist?("test test.TXT"))
|
313
|
+
assert(File.exist?("test test_test.TXT"))
|
314
|
+
assert(File.exist?("teST.jpg.TXT"))
|
315
|
+
assert(File.exist?(".DotFile"))
|
316
|
+
assert(File.exist?("tmp_files2/.DotFile"))
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_trim_first_characters
|
320
|
+
@files << File.new("plop_plop", "w").path
|
321
|
+
@files << File.new("abracadabra.txt", "w").path
|
322
|
+
@files << File.new("abcdefij.klm.txt", "w").path
|
323
|
+
|
324
|
+
r = Renamer.new(@files)
|
325
|
+
r.trim_first(5)
|
326
|
+
|
327
|
+
assert(File.exist?("plop"))
|
328
|
+
assert(File.exist?("adabra.txt"))
|
329
|
+
assert(File.exist?("fij.klm.txt"))
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_trim_last_characters
|
333
|
+
@files << File.new("plop_plouf", "w").path
|
334
|
+
@files << File.new("abracadabra.txt", "w").path
|
335
|
+
@files << File.new("abcdefij.klm.txt", "w").path
|
336
|
+
|
337
|
+
r = Renamer.new(@files)
|
338
|
+
r.trim_last(4)
|
339
|
+
|
340
|
+
assert(File.exist?("plop_p"))
|
341
|
+
assert(File.exist?("abracad.txt"))
|
342
|
+
assert(File.exist?("abcdefij.txt"))
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_date
|
346
|
+
@files << File.new("plop_plouf", "w").path
|
347
|
+
@files << File.new("abracadabra.txt", "w").path
|
348
|
+
|
349
|
+
time = Time.now
|
350
|
+
|
351
|
+
r = Renamer.new(@files)
|
352
|
+
r.current_date(time)
|
353
|
+
|
354
|
+
assert(File.exist?([time.strftime("%Y-%m-%d"), "plop_plouf"].join('_')))
|
355
|
+
assert(File.exist?([time.strftime("%Y-%m-%d"), "abracadabra.txt"].join('_')))
|
356
|
+
end
|
357
|
+
|
358
|
+
def test_datetime
|
359
|
+
@files << File.new("plop_plouf", "w").path
|
360
|
+
@files << File.new("abracadabra.txt", "w").path
|
361
|
+
|
362
|
+
time = Time.now
|
363
|
+
|
364
|
+
r = Renamer.new(@files)
|
365
|
+
r.current_datetime(time)
|
366
|
+
|
367
|
+
assert(File.exist?([time.strftime("%Y-%m-%d_%H-%M"), "plop_plouf"].join('_')))
|
368
|
+
assert(File.exist?([time.strftime("%Y-%m-%d_%H-%M"), "abracadabra.txt"].join('_')))
|
334
369
|
end
|
335
370
|
end
|
data/test/ts_renamer.rb
CHANGED
@@ -18,7 +18,23 @@
|
|
18
18
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
19
|
=end
|
20
20
|
|
21
|
+
|
22
|
+
# Loading needed libs
|
23
|
+
begin
|
24
|
+
require 'rubygems'
|
25
|
+
rescue LoadError
|
26
|
+
warn "Not using RubyGems" if $DEBUG
|
27
|
+
end
|
28
|
+
|
21
29
|
$:.unshift(File.dirname(__FILE__))
|
30
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib/")
|
22
31
|
|
23
32
|
require 'test/unit'
|
24
|
-
require '
|
33
|
+
require 'rubygems'
|
34
|
+
require 'gettext'
|
35
|
+
require 'tempfile'
|
36
|
+
require 'fileutils'
|
37
|
+
require 'const'
|
38
|
+
require 'renamer'
|
39
|
+
|
40
|
+
require 'tc_renamer_procs'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Renamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Cavigneaux
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-10-12 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,14 +50,15 @@ files:
|
|
50
50
|
- doc/TODO.rdoc
|
51
51
|
- lib/const.rb
|
52
52
|
- lib/renamer.rb
|
53
|
-
- po/fr
|
54
53
|
- po/fr/renamer.po
|
55
54
|
- po/renamer.pot
|
56
|
-
- test/
|
55
|
+
- test/tc_renamer_procs.rb
|
57
56
|
- test/ts_renamer.rb
|
58
57
|
- README.rdoc
|
59
58
|
has_rdoc: true
|
60
|
-
homepage: http://
|
59
|
+
homepage: http://www.bitbucket.org/Bounga/renamer/
|
60
|
+
licenses: []
|
61
|
+
|
61
62
|
post_install_message:
|
62
63
|
rdoc_options:
|
63
64
|
- --title
|
@@ -82,9 +83,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
83
|
requirements: []
|
83
84
|
|
84
85
|
rubyforge_project: renamer
|
85
|
-
rubygems_version: 1.3.
|
86
|
+
rubygems_version: 1.3.5
|
86
87
|
signing_key:
|
87
|
-
specification_version:
|
88
|
+
specification_version: 3
|
88
89
|
summary: A fast and light utility to massively rename your files
|
89
90
|
test_files:
|
90
91
|
- test/ts_renamer.rb
|