Skip to content

Instantly share code, notes, and snippets.

@haileys
Created July 24, 2010 10:12
Show Gist options
  • Save haileys/488590 to your computer and use it in GitHub Desktop.
Save haileys/488590 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Changes file extension, e.g:
# $ cext some/file/deeply/nested/file.png .jpg
# $ ls some/file/deeply/nested
# file.jpg
nametokens = ARGV.first.split '.'
newext = ARGV[1].split '.'
File.rename ARGV.first, (nametokens[-newext.length, newext.length] + newext).join '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment