Hi
First off I’m primarily a Windows man so I’m somewhat out of my depth with this.
We have a problem in our production facility with editors creating lots of new files & folders and then leaving them named “untitled”.
This takes up a ton of space on our SAN so I need a script to recurse through the entire SAN and delete every occurance of “untitled” be it a file or folder. This will run once a month via iCal.
I’m thinking along the lines of this code but it only recurses through one branch of the SAN tree.
deleteUntitledFiles(“TSAN:”)
on deleteUntitledFiles(thisFolder)
set fldrPath to thisFolder as string
set theDeathList to {}
repeat with thisName in (list folder thisFolder without invisibles)
set thisItem to alias (fldrPath & thisName)
set theInfo to info for thisItem
-- If an item's a folder then recurse through it
-- Otherwise, check the filename
if theInfo's folder then
deleteUntitledFiles(thisItem)
else if (thisName contains "untitled") then
set the end of theDeathList to thisName
end if
end repeat
-- Use the Finder to delete all the old files in each folder at once
tell the application "Finder"
delete (every file of thisFolder whose name is in theDeathList)
end tell
end deleteUntitledFiles
I also thought of something along the lines of -
get every file of entire contents of disk “TSAN” whose name contains “untitled”
but can’t figure out how to get it intoa list so as to delete it.
Any help greatly appreciated.
cheers
Malcom