Skip to content

Instantly share code, notes, and snippets.

@WardCunningham
Created October 21, 2014 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WardCunningham/354359493c4d0ebc3723 to your computer and use it in GitHub Desktop.
Save WardCunningham/354359493c4d0ebc3723 to your computer and use it in GitHub Desktop.
Restore dates lost copying wiki pages
# 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