Created
February 4, 2014 21:30
-
-
Save ggarnier/8812725 to your computer and use it in GitHub Desktop.
Add date to Octopress posts
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
Dir.glob("source/_posts/*.markdown").each do |filename| | |
formatted_date = filename.split("/").last[0..9] | |
puts "Adding date #{formatted_date} to file #{filename}" | |
lines = [] | |
IO.readlines(filename).map do |line| | |
lines << line | |
lines << "date: #{formatted_date}" if line =~ /^title: / | |
end | |
File.open(filename, 'w') do |file| | |
file.puts lines | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment