Created
January 24, 2013 06:47
-
-
Save EnriqueVidal/4618174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
ARGV.each_with_index do |file, index| | |
next unless File.exists?( file ) | |
filename_arr = File.basename( file ).split '_' | |
# Make sure to add a couple of seconds | |
new_version = Time.now.strftime( '%Y%m%d%H%M%S' ).to_i + index | |
# Change the version | |
filename_arr[0] = new_version | |
new_name = filename_arr.join '_' | |
new_file = File.join File.dirname( file ), new_name | |
# Rename in filesystem | |
FileUtils.mv file, new_file | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment