on removeEmptySubFolders(folderRef)
tell application "Finder"
set folderList to folders of folderRef
repeat with subFolderRef in folderList
reveal subFolderRef
if (count items of subFolderRef) = 0 then
"rm -fr " & (quoted form of POSIX path of (subFolderRef as alias))
try
do shell script the result
beep -- diagnostic
on error
set label index of subFolderRef to 2 -- red, these folders cannot be removed due to permissions
end try
else
open window of subFolderRef
if (current view of window of subFolderRef) ≠ column view then -- I forget why I did this.
my removeEmptySubFolders(subFolderRef)
close window of subFolderRef
if (count items of subFolderRef) = 0 then
"rm -fr " & (quoted form of POSIX path of (subFolderRef as alias))
try
do shell script the result
beep -- diagnostic
on error
set label index of subFolderRef to 2 -- red, these folders cannot be removed due to permissions
end try
end if
end if
end if
end repeat
end tell
end removeEmptySubFolders --------------------------------