Module: EbooksRenamer
- Defined in:
- lib/ebooks_renamer/cli.rb,
lib/ebooks_renamer/version.rb,
lib/ebooks_renamer/pdf_parser.rb,
lib/ebooks_renamer/epub_parser.rb,
lib/ebooks_renamer/mobi_parser.rb,
lib/ebooks_renamer/ebooks_renamer.rb
Defined Under Namespace
Classes: CLI, EpubParser, MobiParser, Parser, PdfParser
Constant Summary collapse
- VERSION =
"0.2.6"
- CustomError =
Class.new(StandardError)
Class Method Summary collapse
Class Method Details
.rename(options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ebooks_renamer/ebooks_renamer.rb', line 4 def rename( = {}) files = CodeLister.files() files.each_with_index do |file, index| # process as many files as possible begin old_name = File.(file) new_name = formatted_name(old_name, [:sep_string]) if old_name != new_name puts "#{index + 1} of #{files.length}: Old name: '#{old_name}'" puts "#{index + 1} of #{files.length}: New name: '#{new_name}'" FileUtils.mv(old_name, new_name) if [:commit] else puts "#{index + 1} of #{files.length}: Result : '#{old_name}' is identical so no action taken." end rescue => e puts "Skip file '#{file}'" puts "Due to the unexpected error: #{e.}" next end end unless [:commit] puts "------------------------------------------------------------------" puts "This is a dry run only, to actually rename please specify --commit" puts "------------------------------------------------------------------" end end |