I’m trying to figure out a way to delete all empty folders within a selected folder. I found a script that worked in OS 9, but it’s not working now with the .ds_store or some other issues. I’m on 10.4.6 btw.
Here is the script in question:
tell application "Finder"
delete (every folder of entire contents of selection whose size is 0)
end tell
Like
delete (every folder of entire contents of selection whose size is “”)
In the mean time I’ve tried the following, and it still doesn’t work, but might give you some other insight as to what I’m trying to do.
set the_container to (choose folder)
tell application "Finder"
set container_list to (folders of container the_container)
repeat with the_sub_container in container_list
set the_sub_container to (the_sub_container as string) as alias
set theItem to item 1 of the_sub_container
if number of file of theItem is 0 and number of folder is 0 then
delete theItem
end if
end repeat
end tell
I’ve tried your suggestion but still get an error about some data could not be transfer into proper type or something.
I’ve included a try statement to eliminate the error just in case it was stock on something for nothing. But the script still didn’t do it’s thing.
tell application "Finder"
set the_folder to choose folder
try
delete (every folder of entire contents of the_folder whose size is missing value)
end try
end tell