Part of the Samples Website. 8/16/97.


«Finds all files with "bogus" dates
«loops over all the files in the folder you select
«looking for files with "bogus" dates
«files created or modified before the Mac shipped
«files created or modified after today (time travel!)
«files modified before they were created
«it confirms all adjustments it makes
local (folder)
if not file.getFolderDialog ("Choose a folder", @folder)
local (ctfixed = 0) «number of bytes reclaimed
local (ctmatches = 0) «number of files with bogus dates
local (confirmationdisabled = false)
local (now = ())
local (cancelled = false)
on confirmation (f, prompt)
if confirmationdisabled
if cancelled
return (false)
return (true)
local (s, result)
s = "The file "" + file.fileFromPath (f) + "" " + prompt
s = s + " Would you like to fix it?"
msg ("Option-yes disables confirmation dialog.")
result = dialog.yesNoCancel (s)
msg ("")
case result
1 «yes
if kb.optionKey ()
confirmationdisabled = true
return (true)
2 «no
return (false)
3 «cancel
cancelled = true
confirmationdisabled = true
return (false)
on bogusCheck (f)
local (created = file.created (f))
local (modified = file.modified (f))
local (macShipDate = date ("January 24, 1984"))
if created < macShipDate
if confirmation (f, "was created before there were any Macintoshes.")
file.setCreated (f, now)
if modified < macShipDate
if confirmation (f, "was modified before there were any Macintoshes.")
file.setModified (f, now)
if created > now
if confirmation (f, "was created in the future.")
file.setCreated (f, now)
if modified > now
if confirmation (f, "was modified in the future.")
file.setModified (f, now)
if created > modified
if confirmation (f, "was created after it was modified.")
file.setCreated (f, modified)
on findInFolder (folder)
fileloop (f in folder)
if cancelled
return (false)
msg (file.fileFromPath (f))
rollBeachBall ()
bogusCheck (f)
if file.isFolder (f)
if not findInFolder (f)
return (false)
findInFolder (folder)
if not cancelled
if ctfixed == 0
s = file.fileFromPath (folder)
if ctmatches > 0
s = "Didn't fix files with bogus dates in the "" + s + "" folder."
s = "All files in the "" + s + "" folder are cool. No bogus dates."
dialog.alert (s)
dialog.alert ("Fixed " + ctfixed + " files with bogus dates!")

This page was last built on Sat, Aug 16, 1997 at 6:36:03 PM. You can download the current set of sample scripts from our FTP site. Dave