ebooks_renamer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ebooks_renamer/ebooks_renamer.rb +14 -7
- data/lib/ebooks_renamer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9e270dd18edb25346badcb75bb5e7b45abe42c9
|
4
|
+
data.tar.gz: 474853d02787a9e64f8d4259145a82106aee0b2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79ac4c29ceec9bed3ef163a5302022b34232535fa2f5c4c57b9c80e9de9667eb6581e35062cd8240b8ce0eca18423f9802f9228ecae38a093bf0e74ddc7cb56f
|
7
|
+
data.tar.gz: 6cfaa16ab0fe43d1e13161460fb2e347d4c7397e194926a2480507ad3be99237f502cc050d784019e4ea0715c0902aa1bed5be4387ff1d624dd2ed40dc2ab4f6
|
@@ -14,13 +14,20 @@ module EbooksRenamer
|
|
14
14
|
def rename(options = {})
|
15
15
|
files = CodeLister.files(options)
|
16
16
|
files.each_with_index do |file, index|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
# process as many files as possible
|
18
|
+
begin
|
19
|
+
new_name = formatted_name(file, options[:sep_string])
|
20
|
+
if file != new_name
|
21
|
+
puts "#{index + 1} of #{files.length}: Old name: '#{file}'"
|
22
|
+
puts "#{index + 1} of #{files.length}: New name: '#{new_name}'"
|
23
|
+
FileUtils.mv(file, new_name) if options[:commit]
|
24
|
+
else
|
25
|
+
puts "#{index + 1} of #{files.length}: Result : '#{file}' is identical so no action taken."
|
26
|
+
end
|
27
|
+
rescue Exception => e
|
28
|
+
puts "Skip file '#{file}'"
|
29
|
+
puts "Due to the unexpected error: #{e.message}"
|
30
|
+
next
|
24
31
|
end
|
25
32
|
end
|
26
33
|
unless options[:commit]
|