lib/lhj/command/rename_image.rb in lhj-tools-0.1.59 vs lib/lhj/command/rename_image.rb in lhj-tools-0.1.60

- old
+ new

@@ -41,9 +41,27 @@ target = File.join(@current_path, m_filename) File.rename(f, target) end end + def list_all_image + sort_list = Dir.glob("#{@current_path}/**/*.{png}").sort { |b, a| File.size(a) <=> File.size(b) } + sort_list.each do |f| + s = File.size(f) + s_s = "#{s}B" + if s > 1024 * 1024 + bf = s / (1024.0 * 1024.0) + s_s = "#{format("%.1f",bf)}MB" + elsif s > 1024 + bf = s / 1024.0 + s_s = "#{format("%.1f",bf)}KB" + else + s_s = "#{s}KB" + end + puts "#{f} #{s_s}" + end + end + def modify_name(file_name, extname) name = file_name.downcase + extname if @image_pre name = @image_pre + file_name.downcase + extname elsif @image_name && @image_other_name