Method: Organize#rename_files
- Defined in:
- lib/organize.rb
#rename_files ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/organize.rb', line 24 def rename_files int = 100000 directory_files.each do |filename| file_date = File.mtime(filename).to_s if !/\d{4}\-\d{2}\-\d{2}/.match(filename[10]) if File.exist?(directory_path + file_date + filename[-4,4]) File.rename(filename, directory_path + file_date + '_' + int.to_s + filename[-4,4]) int += 1 else File.rename(filename, directory_path + file_date + filename[-4,4]) end end end end |