Skip to content

Instantly share code, notes, and snippets.

@hafuu
Created March 25, 2015 04:35
Show Gist options
  • Save hafuu/bc141a78864abf75823d to your computer and use it in GitHub Desktop.
Save hafuu/bc141a78864abf75823d to your computer and use it in GitHub Desktop.
指定したディレクトリ配下のタイムスタンプをリセットするスクリプト
open System
open System.IO
let rec resetDirectory (timestamp: DateTime) path =
printfn "%s" path
Directory.SetCreationTime(path, timestamp)
Directory.SetLastAccessTime(path, timestamp)
Directory.SetLastWriteTime(path, timestamp)
Directory.GetFiles(path) |> Array.iter (resetFile timestamp)
Directory.GetDirectories(path) |> Array.iter (resetDirectory timestamp)
and resetFile (timestamp: DateTime) path =
File.SetCreationTime(path, timestamp)
File.SetLastAccessTime(path, timestamp)
File.SetLastWriteTime(path, timestamp)
let root = fsi.CommandLineArgs.[1]
let timestamp = DateTime.Parse(fsi.CommandLineArgs.[2])
printfn "root: %s, timestamp: %A" root timestamp
resetDirectory timestamp root
printfn "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment