Skip to content

Instantly share code, notes, and snippets.

@alfonsogarciacaro
Created April 25, 2016 15:57
Show Gist options
  • Save alfonsogarciacaro/787af243d3c077a7feb427a278b59881 to your computer and use it in GitHub Desktop.
Save alfonsogarciacaro/787af243d3c077a7feb427a278b59881 to your computer and use it in GitHub Desktop.
Script to compare existing versions of Android image resources
open System
open System.IO
let sep = ";"
let resultsFile = __SOURCE_DIRECTORY__ + "/results.csv"
let resourcePath = "/Users/alfonsogarciacaronunez/Documents/Github/mobile/Joey/Resources"
let limit = DateTime.Today.AddDays(-10.)
let set = System.Collections.Generic.HashSet<string>()
let dic = System.Collections.Generic.Dictionary<string,(string list)>()
Directory.GetDirectories resourcePath
|> Seq.filter (fun x -> x.Contains "drawable")
|> Seq.iter (fun path ->
let dir = Path.GetFileName(path)
set.Add(dir) |> ignore
Directory.GetFiles path
|> Seq.filter (fun x ->
(File.GetLastWriteTimeUtc x) > limit
&& Path.GetExtension(x) = ".png")
|> Seq.map Path.GetFileName
|> Seq.iter (fun file ->
if not (dic.ContainsKey file) then
dic.Add(file, [])
dic.[file] <- dir::dic.[file])
)
// Printing
File.WriteAllLines(resultsFile,
[|
yield sprintf "File%s%s" sep (String.concat sep set)
for k in dic.Keys |> Seq.sort do
yield set
|> Seq.map (fun x -> if List.contains x dic.[k] then "O" else "X")
|> String.concat sep
|> sprintf "%s%s%s" k sep
|])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment