Skip to content

Instantly share code, notes, and snippets.

@yosmoc
Created July 29, 2008 12:58
Show Gist options
  • Save yosmoc/3078 to your computer and use it in GitHub Desktop.
Save yosmoc/3078 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pathname'
if ARGV.length < 1
p 'please input dir name'
else
@dir = Pathname.new(ARGV.shift).expand_path
@join_name = ARGV.join('_')
end
Dir.chdir(@dir.parent)
File.rename(@dir.to_s, @dir.to_s + @join_name)
@dir = Pathname.new(@dir.to_s + @join_name).expand_path
Dir.chdir(@dir)
Dir.entries(@dir).each do |item|
next if item =~ /^\.+$/
basename = File.basename(item, ".*")
extname = File.extname(item)
File.rename(item, basename + @join_name + extname)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment