Skip to content

Instantly share code, notes, and snippets.

@nuna
Created November 25, 2011 02:37
Show Gist options
  • Save nuna/1392687 to your computer and use it in GitHub Desktop.
Save nuna/1392687 to your computer and use it in GitHub Desktop.
指定したディレクトリ以下の特定のファイルを再帰的にリネーム
#!/usr/bin/ruby
require 'find'
require 'fileutils'
dir = ARGV.shift
Find.find(dir) do |f|
if File.file?(f) and /20111123.*\.xls$/ =~ f
FileUtils.mv(f, f.sub(/20111123/, '20111124'), { :noop => false, :verbose => true })
end
end
# > ruby rename.rb <dirname>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment