Created
October 21, 2014 14:18
-
-
Save WardCunningham/354359493c4d0ebc3723 to your computer and use it in GitHub Desktop.
Restore dates lost copying wiki pages
This file contains 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
# This script reads all pages in a repository and sets each file's last modification date | |
# based on dates found in the Journal. | |
require 'json' | |
early = 1335324580000 | |
Dir.glob('../pages/*') do |path| | |
File.open(path) do |file| | |
page = JSON.parse file.read | |
epoch = page['journal'].last['date'] || early | |
time = Time.at(epoch/1000) | |
puts "#{time}\t#{path}" | |
File.utime time, time, path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment