Created
July 16, 2010 02:02
-
-
Save joonyou/477818 to your computer and use it in GitHub Desktop.
rename
This file contains hidden or 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 | |
# | |
if $*.size < 1 | |
puts "usage: rename \"{file search criteria}\" pattern replacement" | |
puts "example: rename \"*\" .MOV .mov" | |
puts " this changes the .MOV to .mov in all files in current directory" | |
else | |
files = Dir.glob "#{$*[0]}" | |
files.each do |f| | |
begin | |
File.rename(f, f.gsub($*[1],$*[2])) | |
rescue | |
puts "FAILED: #{f}" | |
puts $! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment