Skip to content

Instantly share code, notes, and snippets.

@knksmith57
Created February 6, 2014 16:15
Show Gist options
  • Save knksmith57/8847335 to your computer and use it in GitHub Desktop.
Save knksmith57/8847335 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
temp = 'some-temp-file-that-doesnt-exist'
args = ARGV.shuffle!
last = args.last
cur = args.shift
unless !cur.nil?
# need to provide some args!
exit!
end
# start with renaming the first file to temp
File.rename cur, temp
# recurse through all args
args.each do |a|
File.rename a, cur
cur = a
end
# finally, rename the last file back to the one we stored in temp
File.rename temp, cur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment