Adobe Illustrator: Delete Empty Layers

Hello all.

I have only just begun working on scripts and I have hit a wall.
How would I go about selecting and deleting empty layers in Illustrator?
I only found out how to do it in InDesign, as shown below:


tell application "Adobe InDesign CS4"
    activate
    tell active document
        repeat with x from (count layers) to 1 by -1
            get page items of layer x
            if result is {} then
                delete layer x
            end if
        end repeat
    end tell
end tell

Hi. Change “active document” to “document 1.” Delete the extraneous if block, as that’s all obtainable in the previous line.

if (get page items of layer x) is {} then delete layer x

Perfect, Thank you!