Re: Finder - Delete empty folders, recursively
Re: Finder - Delete empty folders, recursively
- Subject: Re: Finder - Delete empty folders, recursively
- From: Graff <email@hidden>
- Date: Mon, 14 Jun 2004 19:25:34 -0400
You should be careful when using this example script. Although it does
work just fine there exists the possibility that it will fail on
folders that have a deep hierarchy, that is they have a lot of folders
nested inside folders.
However it does help in one matter, it will go directly to the deepest
folders and then back out. So if you delete a folder and that's all
that was in the parent then you can delete the parent also. This can
be a bit tricky with other solutions.
Here's the modified example:
----
tell application "Finder"
set theFolder to (folder of the front window)
my ClearEmptyFolder(theFolder)
end tell
on ClearEmptyFolder(whatsPassed)
tell application "Finder"
set theFolders to folders of whatsPassed
repeat with aFolder in theFolders
my ClearEmptyFolder(aFolder)
end repeat
if ((count every item of whatsPassed) = 0) then
display dialog "deleting " & name of whatsPassed
end if
end tell
end ClearEmptyFolder
----
- Ken
On Jun 14, 2004, at 2:42 PM, Paul Kampu wrote:
Hello all!
Here is a script that very nicely deletes every file from every folder
within the parent, recursively. (don't know who wrote this script)
tell application "Finder"
set theRealFolder to (folder of the front window)
my dumpFiles(theRealFolder)
end tell
on dumpFiles(whatsPassed)
tell application "Finder"
delete every file of whatsPassed
set folderContents to (every item of whatsPassed)
repeat with anItem in folderContents
my dumpFiles(anItem)
end repeat
end tell
end dumpFiles
Now the question is...
Does anyone have some idea as to how to modify this script to delete
the
EMPTY folders only? ie. Leave the folders containing files alone.
Or is it better to start from scratch? If so, any suggestions?
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.