A quick and dirty F# script to clean temporary internet files (including Flash cookies which don’t get deleted by the browsers).

QuickAndDirtyCleaner.fsx

open System.IO

let dirs =
  [ @"C:\Documents and Settings\USERNAME\Application Data\Macromedia\Flash Player\macromedia.com\support\flashplayer\sys"
    @"C:\Documents and Settings\USERNAME\Application Data\Macromedia\Flash Player\#SharedObjects"
    @"C:\Documents and Settings\USERNAME\Cookies"
    @"C:\Documents and Settings\USERNAME\Local Settings\Temporary Internet Files"
    @"C:\Documents and Settings\USERNAME\Local Settings\Temp"
  ] |> List.map (fun path ->
          path.Replace("USERNAME", System.Environment.UserName)
        )

let filesWhiteList = [
  "index.dat"
  "hubfs"
  "techcrunch"
  "jiwa"
]

let directoriesWhiteList = []

let isDeletable (path:string) whiteList =
  not <| List.exists (fun pattern -> path.Contains(pattern)) whiteList

let cleanDir dir =
  for path in Directory.GetDirectories dir do
    if isDeletable path directoriesWhiteList then
      try Directory.Delete(path, true) with _ -> ()
  for path in Directory.GetFiles dir do
    if isDeletable path filesWhiteList then
      try File.Delete(path) with _ -> ()

dirs |> List.iter cleanDir

One Response to “Cleaning temporary internet files”

  1. [...] Julien Ortin uses F# to clean up his temporary internet files [...]