i want to delete all files and folders that are unlabeled
i want to delete all files and folders that are unlabeled
- Subject: i want to delete all files and folders that are unlabeled
- From: <email@hidden>
- Date: Mon, 6 Aug 2007 08:39:27 -0700 (PDT)
I want to delete all files and folders that are unlabeled, but when
running on a test folder, sometimes files labeled, say "purple", gets
deleted. I need to reset a variable somewhere to clear them, but not
sure where to put it. This handler is recursive.
Any thoughts?
=============
(*Cleans up all unlabeld files from directory*)
(*The first handler is the "on open" handler that runs when you drop
the top folder
on the Neutron Bomb script droplet. The critical thing to recall in the
"on open" handler is that it doesn't return a reference to the item you
drop on it, but it returns a LIST of references to the item or items
you d ropped on it. In this case, we will only be dropping a single
folder on it -- the one at the top of our folder hierarchy -- so
*)
on open TheFolder
set TheRealFolder to (item 1 of TheFolder) --What is passed to this
handler is the reference to the top folder in our hierarchy.
display dialog "This will delete the non-labeled files in " &
TheFolder & ". To protect files from deleteion, Cancel this and mark
them with a label first." buttons {"Cancel", "OK"} default button 2
Handler_DumpFiles(TheRealFolder)
--set TheRealFolder to ""
end open
on Handler_DumpFiles(WhatsPassed) --What is passed to this handler is
the reference to the top folder in our hierarchy.
set AnItem to ""
tell application "Finder"
--display dialog WhatsPassed as string buttons {"Cancel", "OK"}
default button 2
delete (every file whose label index is 0) of WhatsPassed --tells the
Finder to delete all of the files in that folder
delete (every folder whose label index is 0) of WhatsPassed --tells
the Finder to delete all of the files in that folder
set FolderContents to (every item of WhatsPassed) --Now we can say
that what's left is only the folders, so we make a new list called
folderContents that contains references to all of the folders
repeat with AnItem in FolderContents --We cycle through this list in
a repeat loop treating each folder on its own.
my Handler_DumpFiles(AnItem) --We pass its reference to the
dumpFiles handler (the one we're already in!) and let it process the
contents of that folder too
end repeat
end tell
end Handler_DumpFiles
Thank You,
Thomas Lotzer
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden