Delete Empty Folders

Summary: Moves empty folders to the trash.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2019-10-02


This script moves any empty folders in the library to the trash. 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


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
repeat with _record in _records
if universal type identifier of _record is "public.folder" then
if (count of library records of _record) is 0 then
set container of _record to _trash
my moveEmptyFoldersToTrash(_record, _trash)
end if
end if
end repeat
end tell
end moveEmptyFoldersToTrash