Renamer 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -21,15 +21,14 @@ Renamer can:
21
21
 
22
22
  ===Requirements
23
23
 
24
- Ruby >= 1.8.0 http://www.ruby-lang.org
25
- RubyGem >= 0.8.0 http://rubygem.rubyforge.org
24
+ * Ruby >= 1.8.0 (http://www.ruby-lang.org)
25
+ * RubyGem >= 0.8.0 (http://rubygem.rubyforge.org)
26
26
 
27
27
  ===Install
28
28
 
29
- <tt>
30
- $ su
31
- # gem install -r --source http://download.gna.org/renamer/
32
- </tt>
29
+ <tt>$ su</tt>
30
+
31
+ <tt># gem install Renamer</tt>
33
32
 
34
33
  ===Usage
35
34
 
@@ -38,6 +37,7 @@ $ su
38
37
  ===License
39
38
 
40
39
  Renamer is distributed under the terms of the GNU General Public License.
40
+
41
41
  See the COPYING file for more information.
42
42
 
43
43
  ===Copyright
data/bin/renamer CHANGED
@@ -49,6 +49,7 @@ end
49
49
 
50
50
  require 'optparse'
51
51
  require 'gettext'
52
+ require 'tempfile'
52
53
 
53
54
  require 'const'
54
55
  require 'renamer'
@@ -64,11 +65,12 @@ bindtextdomain("renamer", p)
64
65
  ########################
65
66
  # Command Line Options #
66
67
  ########################
67
- action, arg = nil
68
- recursive = false
68
+ action, arg, $VERBOSE = nil
69
+ recursive, overwrite = false
70
+
69
71
  opts = OptionParser.new
70
72
 
71
- opts.banner = _("Usage: #{File.basename($0)} [options] FILENAMES")
73
+ opts.banner = _("Usage: %s [options] FILENAMES") % File.basename($0)
72
74
  opts.separator ""
73
75
  opts.separator _("Specific options:")
74
76
 
@@ -81,6 +83,8 @@ opts.on("-U", "--underscore", _("Replace underscores by spaces in FILENAMES")) {
81
83
  opts.on("-b", _("--basename BASENAME"), _("Rename FILENAMES using the specified"), _("BASENAME followed by an incremental number")) { |bn| action = :basename; arg = bn }
82
84
  opts.on("-e", _("--ext NEW"), _("Rename FILENAMES from their actual extension"), _("to the NEW one")) { |new| action = :ext; arg = new }
83
85
  opts.on("-r", "--recursive", _("Run %s recursively across directories") % Const::NAME) { recursive = true }
86
+ 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 }
84
88
 
85
89
  opts.separator ""
86
90
  opts.separator _("Common options:")
@@ -101,7 +105,7 @@ filenames = opts.parse(ARGV)
101
105
  ####################
102
106
  # Processing files #
103
107
  ####################
104
- r = Renamer.new(filenames, recursive)
108
+ r = Renamer.new(filenames, recursive, overwrite)
105
109
 
106
110
  case action
107
111
  when :downcase
@@ -120,4 +124,4 @@ when :basename
120
124
  r.basename(arg)
121
125
  when :ext
122
126
  r.ext(arg)
123
- end
127
+ end
data/doc/BUGS CHANGED
@@ -1,7 +1,6 @@
1
1
  = Renamer - The perfect tool to easily rename your files
2
2
 
3
3
  == Known bugs:
4
- Last Modified: 2004-12-30
4
+ Last Modified: 2006-04-24
5
5
 
6
- * Using of wildcards on the command-line only works for unix shells we must use Dir[]
7
- if we want this feature to be available on other systems (MS-Windows for example).
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).
data/doc/ChangeLog CHANGED
@@ -1,6 +1,53 @@
1
1
  = Renamer - The perfect tool to easily rename your files
2
2
 
3
3
 
4
+ === Renamer 0.5.0
5
+
6
+ 2006-04-24 Nicolas Cavigneaux <nico@bounga.org>
7
+
8
+ * Added overwrite mode
9
+ * Added Unit Tests
10
+ * Updated documentation
11
+ * Updated POT file
12
+ * Updated french translation
13
+ * Improved Rakefile
14
+
15
+ 2006-04-24 Nicolas Cavigneaux <nico@bounga.org>
16
+
17
+ * Corrected bug in Renamer#ext() (don't process dotfiles even in subdirectories)
18
+ * Added Unit Test
19
+
20
+ 2006-03-13 Nicolas Cavigneaux <nico@bounga.org>
21
+
22
+ * Updated doc
23
+
24
+ 2006-02-05 Nicolas Cavigneaux <nico@bounga.org>
25
+
26
+ * Updated Rakefile
27
+ * Corrected i18n strings displaying bug
28
+ * Updated POT file
29
+ * Updated french translation
30
+
31
+ 2006-01-26 Nicolas Cavigneaux <nico@bounga.org>
32
+
33
+ * Updated info about how to install Renamer
34
+
35
+ 2006-01-16 Nicolas Cavigneaux <nico@bounga.org>
36
+
37
+ * Added verbose/quiet modes
38
+ * Updated TODO, doc/renamer files
39
+ * Updated error messages
40
+ * Updated french translation
41
+ * Corrected typo in french translation
42
+
43
+ 2006-01-13 Nicolas Cavigneaux <nico@bounga.org>
44
+
45
+ * Improved "rename_fs" method (now use Tempfile class)
46
+ * Improved renaming, it now uses absolute pathnames
47
+ * Added a "require" to test/tc_renamer.rb to make it works with
48
+ Tempfile class
49
+ * Updated TODO file
50
+
4
51
  === Renamer 0.4.0
5
52
 
6
53
  2006-01-07 Nicolas Cavigneaux <nico@bounga.org>
@@ -139,4 +186,4 @@
139
186
 
140
187
  * Lowercase the filenames
141
188
  * Uppercase the filenames
142
- * Delete spaces in the filenames
189
+ * Delete spaces in the filenames
data/doc/FAQ CHANGED
@@ -1,6 +1,6 @@
1
1
  = Renamer - The perfect tool to easily rename your files
2
2
 
3
- <em>Last Modified: 2005-12-08</em>
3
+ <em>Last Modified: 2006-01-26</em>
4
4
 
5
5
 
6
6
  == 1. Installing
@@ -22,7 +22,7 @@ on the command-line if it is well installed.
22
22
  To install Renamer from the official gem, you just must have the Gem packaging
23
23
  system installed (http://rubygems.rubyforge.org) and type
24
24
 
25
- <tt># gem install -r --source http://download.gna.org/renamer/</tt>
25
+ <tt># gem install Renamer</tt>
26
26
 
27
27
  and if you've already downloaded the gem, you have to type :
28
28
 
@@ -41,8 +41,8 @@ This will install all the required files in the good directories. That's all, yo
41
41
 
42
42
  Because Renamer makes it easy to rename any number of files on any filesystem
43
43
  without knowing anything about shell scripting or regular expressions (regexp).
44
- Renamer is able to lowercase, uppercase, delete white-spaces and a lot more on
45
- all file systems.
44
+ Renamer is able to lowercase, uppercase, delete white-spaces and a lot more. It's
45
+ fast, light and always evolving.
46
46
 
47
47
  === 2.2. I've launched Renamer, but I'm lost, what can I do?
48
48
 
@@ -95,4 +95,4 @@ available in the package.
95
95
  === 3.6. Can I give money or other things to Renamer developers?
96
96
 
97
97
  If you really want to do this you can. You should contact a developer to know
98
- what to do.
98
+ what to do.
data/doc/TODO CHANGED
@@ -8,16 +8,13 @@ the mailto:renamer-dev@gna.org mailing list.
8
8
 
9
9
  === Before next release
10
10
 
11
- * Verbose/Quiet modes
12
- * Overwrite mode
13
11
  * Add a method to lowercase/uppercase extensions only
14
- * Improve "run" method, we should work on absolute pathnames
15
- * Improve "rename_fs" method (add a random number to the tmp file)
16
12
  * Improve execution speed (Benchmark and profile)
17
13
 
18
14
 
19
15
  === Future releases
20
16
 
21
- * Nothing yet ! Any idea ?
17
+ * Add a method to rename files using current date/time
18
+ * Add a method to delete the "n" first/last characters
22
19
 
23
20
  (Doned items are moved to ChangeLog file)
data/doc/renamer CHANGED
@@ -9,8 +9,6 @@
9
9
  Permission is granted to copy, distribute and/or modify this document
10
10
  under the terms of the {GNU General Public License}[http://www.gnu.org/copyleft/gpl.html], Version 2 or later.
11
11
 
12
- Last release of this documentation can be downloaded at: http://renamer.bounga.org/index.php?page=doc
13
-
14
12
  == Introduction
15
13
 
16
14
  === Description
@@ -29,7 +27,7 @@ Its main features are :
29
27
  * rename filenames from their actual extension to the specified one
30
28
  * recursive actions
31
29
  * run on various operating systems (Gnu/Linux, *BSD, Microsoft Windows, ...)
32
- * 100% GPL, freesoftware
30
+ * 100% GPL, free software
33
31
 
34
32
  Renamer official website is available at: http://renamer.bounga.org
35
33
 
@@ -40,7 +38,6 @@ To install Renamer, you must have:
40
38
  * RubyGem packaging system (>= 0.8.0) (http://rubygems.rubyforge.org)
41
39
  * "root" privileges on your system
42
40
 
43
-
44
41
  == Installation
45
42
 
46
43
  Renamer package can be downloaded at: http://download.gna.org/renamer/Renamer.gem. This link always points to
@@ -58,15 +55,13 @@ Or you can use gem to automatically download and install the lastest release of
58
55
 
59
56
  <tt>$ su</tt>
60
57
 
61
- <tt># gem install -r --source http://download.gna.org/renamer/</tt>
62
-
63
- Developers can be interested in downloading the CVS sources to be able to try or code on the latest
64
- version of Renamer. But take care, these sources are development files and are reserved to advanced
65
- users. Using these sources Renamer could be very instable or even unusable. To get the CVS sources,
66
- use the following command:
67
-
68
- <tt>cvs -d:pserver:anonymous@cvs.gna.org:/cvs/renamer co renamer</tt>
58
+ <tt># gem install Renamer</tt>
69
59
 
60
+ Developers can be interested in downloading the latest sources to be able to try or code on Renamer.
61
+ But take care, these sources are development files and are reserved to advanced users. Using these
62
+ sources Renamer could be very instable or even unusable. To get the latest sources, you should contact a
63
+ developer, see: http://gna.org/project/memberlist.php?group=renamer. Renamer is maintain using {Mercurial SCM}[http://www.selenic.com/mercurial/]
64
+ so you should read about it if you want to develop on this project.
70
65
 
71
66
  == Usage
72
67
 
@@ -88,11 +83,13 @@ Available options for Renamer are:
88
83
  * -U, --underscore : Replace underscores by spaces in filenames
89
84
  * -b, --basename : Rename filenames using the specified basename followed by an incremental number
90
85
  * -e, --ext : Rename filenames from their actual extension to the specified one
86
+ * -r, --recursive : Run Renamer recursively across directories
87
+ * -o, --overwrite : Overwrite existing files if needed
88
+ * -V, --verbose : Run Renamer in verbose mode (quiet by default)
91
89
  * -h, --help : Show some help
92
90
  * -v, --version : Show Renamer version
93
91
  * -l, --license : Show some information about Renamer license
94
92
 
95
-
96
93
  == Authors / Support
97
94
 
98
95
  === Authors
@@ -120,4 +117,4 @@ This manual documents Renamer software, it's part of Renamer.
120
117
 
121
118
  Copyright (c) 2004-2006 Nicolas Cavigneaux <nico@bounga.org>
122
119
 
123
- This document can be use under the terms of the {GNU General Public License}[http://www.gnu.org/copyleft/gpl.html], Version 2 or later.
120
+ This document can be use under the terms of the {GNU General Public License}[http://www.gnu.org/copyleft/gpl.html], Version 2 or later.
data/lib/const.rb CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
  module Const
21
21
  NAME = "Renamer"
22
- VER = "0.4.0"
22
+ VER = "0.4.2"
23
23
  LICENSE = "
24
24
  Copyright (c) 2004-2006 by Nicolas Cavigneaux <nico@bounga.org>
25
25
  See COPIYNG for License detail.
data/lib/renamer.rb CHANGED
@@ -17,14 +17,23 @@
17
17
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
18
  =end
19
19
 
20
- # Class to handle a list of files to rename
20
+ ########################
21
+ # Initiliazing GetText #
22
+ ########################
21
23
  include GetText
24
+ # Searching the path to locale directory
25
+ p = File.join(File.dirname(__FILE__), "/../locale/")
26
+ bindtextdomain("renamer", p)
22
27
 
28
+ # Class Renamer handles files renaming
23
29
  class Renamer
24
- EXISTS = _("%s: The destination file already exists!") % Const::NAME
30
+ EXISTS = _("%s: %s file already exists!")
25
31
 
26
32
  # Create a new Renamer object
27
- def initialize(filenames, recursive = false)
33
+ def initialize(filenames, recursive = false, overwrite = false)
34
+ # Whether user wants to overwrite existing files or not
35
+ @overwrite = overwrite
36
+
28
37
  # User wants to process files recursively
29
38
  if recursive
30
39
  @filenames = Array.new
@@ -132,7 +141,7 @@ class Renamer
132
141
  def ext(e)
133
142
  proc_ext = Proc.new do |file, extension|
134
143
  # We don't want to process dotfiles
135
- unless file =~ /^\./ # BUG : Don't work on subdirectories
144
+ unless File.basename(file) =~ /^\./
136
145
  # We want to remove the last extension
137
146
  name = file.split(".")
138
147
  name = name[0...-1].join(".") if name.size > 1
@@ -151,37 +160,42 @@ private
151
160
  @filenames.each do |file|
152
161
  if File.exist?(file) then
153
162
  if File.writable?(file) then
154
- # TODO: Improve the processing, we should work on absolute pathnames rather than
155
- # switching from a directory to another one for each file
156
- cur_dir = Dir.pwd
157
- Dir.chdir(File.dirname(file))
158
- a_proc.call(File.basename(file), *others)
159
- Dir.chdir(cur_dir)
163
+ a_proc.call(file, *others)
160
164
  else
161
165
  warn _("%s: You don't have write access on %s") % [Const::NAME, file]
162
166
  end
163
167
  else
164
- warn _("%s: File \"%s\" doesn't exists!") % [Const::NAME, file]
168
+ warn _("%s: File %s doesn't exists!") % [Const::NAME, file]
165
169
  end
166
170
  end
167
171
  end
168
172
 
169
173
  # Helper to rename files
170
174
  def rename(old, new)
171
- if not File.exist?(new) then
175
+ unless File.exist?(new) and @overwrite == false
176
+ # Expanding paths to make them reliable
177
+ old = File.expand_path(old)
178
+ new = File.join(File.dirname(old), File.basename(new))
179
+ # Renaming the file
172
180
  File.rename(old, new)
173
181
  else
174
- warn EXISTS
182
+ warn EXISTS % [Const::NAME, new]
175
183
  end
176
184
  end
177
185
 
178
186
  # Helper to rename files ensuring compatibily on all FS
179
187
  def rename_fs(old, new)
180
- unless File.exist?(new)
181
- File.rename(old, "#{old}.tmp")
182
- File.rename("#{old}.tmp", new)
188
+ unless File.exist?(new) and @overwrite == false
189
+ # Expanding paths to make them reliable
190
+ old = File.expand_path(old)
191
+ new = File.join(File.dirname(old), File.basename(new))
192
+ # Renaming the file
193
+ tf = Tempfile.new("renamer")
194
+ File.rename(old, tf.path)
195
+ File.rename(tf.path, new)
196
+ tf.close(true)
183
197
  else
184
- warn EXISTS
198
+ warn EXISTS % [Const::NAME, new]
185
199
  end
186
200
  end
187
- end
201
+ end
data/po/fr/renamer.po CHANGED
@@ -1,105 +1,115 @@
1
1
  # translation of renamer.po to Français
2
- # translation of fr.po to Français
3
2
  # French translations for Renamer
4
3
  # Copyright (C) 2005-2006 Nicolas Cavigneaux <nico@bounga.org>
5
4
  # This file is distributed under the same license as Renamer.
6
- # Nicolas Cavigneaux <nico@bounga.org>, 2005, 2006.
7
5
  #
6
+ # Nicolas Cavigneaux <nico@bounga.org>, 2005, 2006.
8
7
  msgid ""
9
8
  msgstr ""
10
9
  "Project-Id-Version: renamer\n"
11
- "POT-Creation-Date: 2006-01-07 21:42+0100\n"
12
- "PO-Revision-Date: 2006-01-07 21:44+0100\n"
10
+ "POT-Creation-Date: 2006-04-26 20:37+0200\n"
11
+ "PO-Revision-Date: 2006-04-26 20:39+0200\n"
13
12
  "Last-Translator: Nicolas Cavigneaux <nico@bounga.org>\n"
14
13
  "Language-Team: Français <fr@li.org>\n"
15
14
  "MIME-Version: 1.0\n"
16
15
  "Content-Type: text/plain; charset=UTF-8\n"
17
16
  "Content-Transfer-Encoding: 8bit\n"
18
17
  "Plural-Forms: nplurals=2; plural=(n > 1);\n"
19
- "X-Generator: KBabel 1.10.2\n"
18
+ "X-Generator: KBabel 1.11.2\n"
20
19
 
21
20
  #: bin/renamer:73
21
+ msgid "Usage: %s [options] FILENAMES"
22
+ msgstr "Utilisation : %s [options] FICHIERS"
23
+
24
+ #: bin/renamer:75
22
25
  msgid "Specific options:"
23
26
  msgstr "Options spécifiques :"
24
27
 
25
- #: bin/renamer:75
28
+ #: bin/renamer:77
26
29
  msgid "Downcase FILENAMES"
27
30
  msgstr "Mettre FICHIERS en minuscules"
28
31
 
29
- #: bin/renamer:76
32
+ #: bin/renamer:78
30
33
  msgid "Upcase FILENAMES"
31
34
  msgstr "Mettre FICHIERS en majuscules"
32
35
 
33
- #: bin/renamer:77
36
+ #: bin/renamer:79
34
37
  msgid "Capitalize FILENAMES"
35
38
  msgstr "Capitalise FICHIERS"
36
39
 
37
- #: bin/renamer:78
40
+ #: bin/renamer:80
38
41
  msgid "Capitalize each words in FILENAMES"
39
42
  msgstr "Capitalise chaque mot dans FICHIERS"
40
43
 
41
- #: bin/renamer:79
42
- #, fuzzy
44
+ #: bin/renamer:81
43
45
  msgid "Replace spaces by underscores in FILENAMES"
44
- msgstr "Capitalise chaque mot dans FICHIERS"
46
+ msgstr "Transforme les espaces dans FICHIERS par des blancs soulignés"
45
47
 
46
- #: bin/renamer:80
48
+ #: bin/renamer:82
47
49
  msgid "Replace underscores by spaces in FILENAMES"
48
50
  msgstr "Remplace les blancs soulignés par des espaces dans FICHIERS "
49
51
 
50
- #: bin/renamer:81
52
+ #: bin/renamer:83
51
53
  msgid "--basename BASENAME"
52
54
  msgstr "--basename NOM_DE_BASE"
53
55
 
54
- #: bin/renamer:81
56
+ #: bin/renamer:83
55
57
  msgid "Rename FILENAMES using the specified"
56
58
  msgstr "Renomme FICHIERS. en utilisant le"
57
59
 
58
- #: bin/renamer:81
60
+ #: bin/renamer:83
59
61
  msgid "BASENAME followed by an incremental number"
60
62
  msgstr "NOM_DE_BASE spécifié suivit d'un nombre incrémental"
61
63
 
62
- #: bin/renamer:82
64
+ #: bin/renamer:84
63
65
  msgid "--ext NEW"
64
66
  msgstr "--ext NOUVELLE"
65
67
 
66
- #: bin/renamer:82
68
+ #: bin/renamer:84
67
69
  msgid "Rename FILENAMES from their actual extension"
68
70
  msgstr "Renomme FICHIERS de leur extension actuelle"
69
71
 
70
- #: bin/renamer:82
72
+ #: bin/renamer:84
71
73
  msgid "to the NEW one"
72
74
  msgstr "à la NOUVELLE"
73
75
 
74
- #: bin/renamer:83
76
+ #: bin/renamer:85
75
77
  msgid "Run %s recursively across directories"
76
78
  msgstr "Éxécute %s récurisivement à travers les répertoires"
77
79
 
78
80
  #: bin/renamer:86
81
+ msgid "Overwrite existing files if needed"
82
+ msgstr "Écrase les fichiers existants si nécessaire"
83
+
84
+ #: bin/renamer:87
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
79
89
  msgid "Common options:"
80
90
  msgstr "Options habituelles"
81
91
 
82
- #: bin/renamer:88
92
+ #: bin/renamer:92
83
93
  msgid "Show this help"
84
94
  msgstr "Affiche cette aide"
85
95
 
86
- #: bin/renamer:89
96
+ #: bin/renamer:93
87
97
  msgid "Show %s version"
88
98
  msgstr "Affiche la version de %s"
89
99
 
90
- #: bin/renamer:90
100
+ #: bin/renamer:94
91
101
  msgid "Show some information about %s license"
92
102
  msgstr "Affiche quelques informations à propos de la licence de %s"
93
103
 
94
- #: lib/renamer.rb:24
95
- msgid "%s: The destination file already exists!"
96
- msgstr "%s : Le fichier de destination existe déjà !"
104
+ #: lib/renamer.rb:30
105
+ msgid "%s: %s file already exists!"
106
+ msgstr "%s : Le fichier %s existe déjà !"
97
107
 
98
- #: lib/renamer.rb:161
108
+ #: lib/renamer.rb:165
99
109
  msgid "%s: You don't have write access on %s"
100
110
  msgstr "%s : Vous n'avez pas les droits en écriture sur %s"
101
111
 
102
- #: lib/renamer.rb:164
103
- msgid "%s: File \"%s\" doesn't exists!"
104
- msgstr "%s : Le fichier \"%s\" n'existe pas !"
112
+ #: lib/renamer.rb:168
113
+ msgid "%s: File %s doesn't exists!"
114
+ msgstr "%s : Le fichier %s n'existe pas !"
105
115
 
data/po/renamer.pot CHANGED
@@ -6,8 +6,8 @@
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: 0.4.0\n"
10
- "POT-Creation-Date: 2006-01-07 21:43+0100\n"
9
+ "Project-Id-Version: 0.4.1\n"
10
+ "POT-Creation-Date: 2006-04-26 20:37+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"
@@ -17,85 +17,97 @@ msgstr ""
17
17
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
18
18
 
19
19
  #: bin/renamer:73
20
- msgid "Specific options:"
20
+ msgid "Usage: %s [options] FILENAMES"
21
21
  msgstr ""
22
22
 
23
23
  #: bin/renamer:75
24
+ msgid "Specific options:"
25
+ msgstr ""
26
+
27
+ #: bin/renamer:77
24
28
  msgid "Downcase FILENAMES"
25
29
  msgstr ""
26
30
 
27
- #: bin/renamer:76
31
+ #: bin/renamer:78
28
32
  msgid "Upcase FILENAMES"
29
33
  msgstr ""
30
34
 
31
- #: bin/renamer:77
35
+ #: bin/renamer:79
32
36
  msgid "Capitalize FILENAMES"
33
37
  msgstr ""
34
38
 
35
- #: bin/renamer:78
39
+ #: bin/renamer:80
36
40
  msgid "Capitalize each words in FILENAMES"
37
41
  msgstr ""
38
42
 
39
- #: bin/renamer:79
43
+ #: bin/renamer:81
40
44
  msgid "Replace spaces by underscores in FILENAMES"
41
45
  msgstr ""
42
46
 
43
- #: bin/renamer:80
47
+ #: bin/renamer:82
44
48
  msgid "Replace underscores by spaces in FILENAMES"
45
49
  msgstr ""
46
50
 
47
- #: bin/renamer:81
51
+ #: bin/renamer:83
48
52
  msgid "--basename BASENAME"
49
53
  msgstr ""
50
54
 
51
- #: bin/renamer:81
55
+ #: bin/renamer:83
52
56
  msgid "Rename FILENAMES using the specified"
53
57
  msgstr ""
54
58
 
55
- #: bin/renamer:81
59
+ #: bin/renamer:83
56
60
  msgid "BASENAME followed by an incremental number"
57
61
  msgstr ""
58
62
 
59
- #: bin/renamer:82
63
+ #: bin/renamer:84
60
64
  msgid "--ext NEW"
61
65
  msgstr ""
62
66
 
63
- #: bin/renamer:82
67
+ #: bin/renamer:84
64
68
  msgid "Rename FILENAMES from their actual extension"
65
69
  msgstr ""
66
70
 
67
- #: bin/renamer:82
71
+ #: bin/renamer:84
68
72
  msgid "to the NEW one"
69
73
  msgstr ""
70
74
 
71
- #: bin/renamer:83
75
+ #: bin/renamer:85
72
76
  msgid "Run %s recursively across directories"
73
77
  msgstr ""
74
78
 
75
79
  #: bin/renamer:86
80
+ msgid "Overwrite existing files if needed"
81
+ msgstr ""
82
+
83
+ #: bin/renamer:87
84
+ msgid "Run %s in verbose mode (quiet by default)"
85
+ msgstr ""
86
+
87
+ #: bin/renamer:90
76
88
  msgid "Common options:"
77
89
  msgstr ""
78
90
 
79
- #: bin/renamer:88
91
+ #: bin/renamer:92
80
92
  msgid "Show this help"
81
93
  msgstr ""
82
94
 
83
- #: bin/renamer:89
95
+ #: bin/renamer:93
84
96
  msgid "Show %s version"
85
97
  msgstr ""
86
98
 
87
- #: bin/renamer:90
99
+ #: bin/renamer:94
88
100
  msgid "Show some information about %s license"
89
101
  msgstr ""
90
102
 
91
- #: lib/renamer.rb:24
92
- msgid "%s: The destination file already exists!"
103
+ #: lib/renamer.rb:30
104
+ msgid "%s: %s file already exists!"
93
105
  msgstr ""
94
106
 
95
- #: lib/renamer.rb:161
107
+ #: lib/renamer.rb:165
96
108
  msgid "%s: You don't have write access on %s"
97
109
  msgstr ""
98
110
 
99
- #: lib/renamer.rb:164
100
- msgid "%s: File \"%s\" doesn't exists!"
111
+ #: lib/renamer.rb:168
112
+ msgid "%s: File %s doesn't exists!"
101
113
  msgstr ""
data/test/tc_renamer.rb CHANGED
@@ -30,6 +30,7 @@ $:.unshift(File.dirname(__FILE__) + "/../lib/")
30
30
  require 'test/unit'
31
31
  require 'rubygems'
32
32
  require 'gettext'
33
+ require 'tempfile'
33
34
  require 'fileutils'
34
35
  require 'const'
35
36
  require 'renamer'
@@ -91,6 +92,29 @@ class TestRenamer < Test::Unit::TestCase
91
92
  assert_nothing_raised(Errno::ENOENT) { File.open("test2/plop.txt") }
92
93
  end
93
94
 
95
+ def test_overwrite
96
+ # First we test that it doesn't overwrite when overwrite is false
97
+ @files << File.new("plop_plop", "w").path
98
+ @files << File.new("plop plop", "w").path
99
+
100
+ r = Renamer.new(@files, false, false)
101
+ r.underscore_to_space
102
+
103
+ assert_nothing_raised(Errno::ENOENT) { File.open("plop_plop") }
104
+ assert_nothing_raised(Errno::ENOENT) { File.open("plop plop") }
105
+
106
+ # Now we test that files are overwrited when overwrite is true
107
+ @files.clear
108
+ @files << File.new("test_test", "w").path
109
+ @files << File.new("test test", "w").path
110
+
111
+ r = Renamer.new(@files, false, true)
112
+ r.underscore_to_space
113
+
114
+ assert_raise(Errno::ENOENT) { File.open("test_test") }
115
+ assert_nothing_raised(Errno::ENOENT) { File.open("test test") }
116
+ end
117
+
94
118
  def test_downcase
95
119
  @files << File.new("PLOP", "w").path
96
120
  @files << File.new("PLOP.txt", "w").path
@@ -240,6 +264,8 @@ class TestRenamer < Test::Unit::TestCase
240
264
  @files << File.new("test test_test.txt", "w").path
241
265
  @files << File.new("teST.jpg.txt", "w").path
242
266
  @files << File.new(".dotfile", "w").path
267
+ Dir.mkdir("tmp_files2")
268
+ @files << File.new("tmp_files2/.dotfile", "w").path
243
269
 
244
270
  r = Renamer.new(@files)
245
271
  r.ext("rnm")
@@ -252,5 +278,6 @@ class TestRenamer < Test::Unit::TestCase
252
278
  assert_nothing_raised(Errno::ENOENT) { File.open("test test_test.rnm") }
253
279
  assert_nothing_raised(Errno::ENOENT) { File.open("teST.jpg.rnm") }
254
280
  assert_nothing_raised(Errno::ENOENT) { File.open(".dotfile") }
281
+ assert_nothing_raised(Errno::ENOENT) { File.open("tmp_files2/.dotfile") }
255
282
  end
256
283
  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.0
7
- date: 2006-01-07 00:00:00 +01:00
6
+ version: 0.4.2
7
+ date: 2006-05-02 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
@@ -29,25 +29,22 @@ authors:
29
29
  - Nicolas Cavigneaux
30
30
  files:
31
31
  - bin/renamer
32
- - doc/FAQ
33
32
  - doc/AUTHORS
34
33
  - doc/BUGS
35
34
  - doc/COPYING
35
+ - doc/ChangeLog
36
+ - doc/FAQ
36
37
  - doc/HACKING
37
- - doc/renamer
38
38
  - doc/TODO
39
+ - doc/renamer
39
40
  - doc/renamer.1.gz
40
- - doc/ChangeLog
41
41
  - lib/const.rb
42
42
  - lib/renamer.rb
43
- - po/renamer.pot
44
43
  - po/fr
44
+ - po/renamer.pot
45
45
  - po/fr/renamer.po
46
- - locale/fr
47
- - locale/fr/LC_MESSAGES
48
- - locale/fr/LC_MESSAGES/renamer.mo
49
- - test/ts_renamer.rb
50
46
  - test/tc_renamer.rb
47
+ - test/ts_renamer.rb
51
48
  - README
52
49
  test_files:
53
50
  - test/ts_renamer.rb
Binary file