Skip to content

Instantly share code, notes, and snippets.

@michaelbarton
Created March 6, 2011 17:20
Show Gist options
  • Save michaelbarton/857420 to your computer and use it in GitHub Desktop.
Save michaelbarton/857420 to your computer and use it in GitHub Desktop.
Dir['content/markup/*/*'].each do |file|
file =~ /\d+-\d+-\d+/
date = Regexp.last_match(0) + ' 00:00 GMT'
file =~ /\d+-\d+-\d+-(.+).markdown$/
title = Regexp.last_match(1)
english_title = title.gsub('-',' ').capitalize
content = File.open(file) do |pipe|
pipe.readline
tmp = pipe.readline
while(tmp.strip != '---') do
tmp = pipe.readline
end
pipe.read
end
target = File.dirname(file) + "/#{title}.markdown"
File.delete(file)
File.open(target,'w') do |out|
out.puts '---'
out.puts ' kind: article'
out.puts ' created_at: ' + date
out.puts ' title: ' + english_title
out.puts '---'
out.puts content
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment