REBOL [
    Title: "Brutal Delete"
    Author: "Christopher Ross-Gill"
    Date: 9-Jan-2007
]

get-subfolders: func [folder /deep /local tree files][
    tree: []
    any [deep clear tree]
    insert tree folder: dirize folder
    files: read folder
    foreach file files [
        if dir? folder/:file [get-subfolders/deep folder/:file]
    ]
    tree
]

delete: func [[catch] target [url!] /pare /local path folder err][
    either error? set/any 'err try [
        ; Delete Children
        if dir? target [
            folder: get-subfolders target
            foreach path folder [close clear open path]
        ]

        ; Delete Target
        set [path target] split-path target
        folder: open path
        remove find folder target
        close folder

        ; Delete Empty Parents
        if pare [
            while [
                pare: empty? folder: open path
                close folder
                pare
            ][
                set [path target] split-path path
                folder: open path
                remove find folder target
                close folder
            ]
        ]
    ][throw err][path]
]