Delete Empty Folders
Summary: Moves empty folders to the trash.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2022-10-28
Description
This script moves any empty folders in the library to the trash. By default, a folder is considered empty if it has no contents or only contains other empty folders. This can be useful if EagleFiler is set to skip duplicate files when importing, so that if you import two similar folder hierarchies you end up with lots of empty folders.
Installation Instructions · Download in Compiled Format · Download in Text Format
Script
property
countFoldersOfEmptyFoldersAsEmpty :
true
on
run
tell
application
"EagleFiler"
tell
library document
1
my
moveEmptyFoldersToTrash(
root folder,
trash)
end
tell
end
tell
end
run
on
moveEmptyFoldersToTrash(
_folderRecord,
_trash)
tell
application
"EagleFiler"
set
_records
to
library records
of
_folderRecord
whose
is folder
is
true
repeat
with
_record
in
_records
if
countFoldersOfEmptyFoldersAsEmpty
then
my
moveEmptyFoldersToTrash(
_record,
_trash)
end
if
if
(
count
of
library records
of
_record)
is
0
then
set
container
of
_record
to
_trash
else
if
not
countFoldersOfEmptyFoldersAsEmpty
then
my
moveEmptyFoldersToTrash(
_record,
_trash)
end
if
end
repeat
end
tell
end
moveEmptyFoldersToTrash