Skip to content

Instantly share code, notes, and snippets.

@tasugim
Created February 11, 2019 08:55
Show Gist options
  • Select an option

  • Save tasugim/883a444917b7deb7f7ade0e949c01233 to your computer and use it in GitHub Desktop.

Select an option

Save tasugim/883a444917b7deb7f7ade0e949c01233 to your computer and use it in GitHub Desktop.
Octopressの記事ファイルをHugoに移行するためにリネームする。
require 'fileutils'
pattern = /\d{4}-\d{2}-\d{2}-(.*)\.markdown/
Dir.glob('./*.markdown').each do |file|
old_name = File.basename(file)
next unless (md = old_name.match(pattern))
new_name = "#{md[1]}.md"
FileUtils.mv(old_name, new_name)
puts "rename #{old_name} to #{new_name}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment