Skip to content

Instantly share code, notes, and snippets.

@mikehale
Last active September 3, 2019 14:28
Show Gist options
  • Save mikehale/541591d1af375f2d5e3b22bc90432b71 to your computer and use it in GitHub Desktop.
Save mikehale/541591d1af375f2d5e3b22bc90432b71 to your computer and use it in GitHub Desktop.
# To install this script as a context menu item, add this to the registry:
# key: \HKEY_CLASSES_ROOT\*\shell\Backup\command
# default data: C:\Ruby26-x64\bin\rubyw.exe C:\Scripts\backup.rb "%1"
# And place this file at C:\Scripts\backup.rb
require 'fileutils'
require 'time'
src = ARGV.first
exit unless src
src_extension = File.extname(src)
src_basename = File.basename(src, src_extension)
time = Time.now.utc.iso8601
dest = "#{src_basename}_#{time}#{src_extension}"
FileUtils.cp(src, dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment