Skip to content

Instantly share code, notes, and snippets.

@smcabrera
Last active July 22, 2017 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smcabrera/2a6709a1448ab6e0fd376775b1b46603 to your computer and use it in GitHub Desktop.
Save smcabrera/2a6709a1448ab6e0fd376775b1b46603 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# frozen_string_literal: true
ARGV.each do |original_file|
unless File.exist? original_file
puts "#{original_file} does not exist"
next
end
timestamp = Time.now.utc.strftime("%Y%m%d%s")
file_parts = original_file.match(/(.*)\.(png|jpg)/)
new_file = "#{file_parts[1]}-#{timestamp}.#{file_parts[2]}"
puts "Changing #{original_file} to #{new_file}"
`mv #{original_file} #{new_file}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment