Recursively delete empty folders in Lua
Since you're not updating the variables path, rootPath and currentPath anywhere, use a single variable.

Define the function walk locally.

You can also break out of your c_GetFileDir loop once you've updated the empty flag. This will remove the time to iterate through all children of a directory.


  The help pages for WFTPServer have a 
  different return values for c_GetFileDir than
  yours!


function EmptyFolderDeleter( options )
    local root = options.path

    local walk = function( path )

        --cycle through the current directory, walking directories
        for dir in c_GetDir( path ) do
            walk( path..dir.."/" )
        end

        --if we've got this far then we're at the bottom of the tree
        --there are no more directories to visit
        --now check if there is ANYTHING (file or folder) in the current folder 
        local empty = true
        for isdir, file in c_GetFileDir( path ) do
            empty = false
            break
        end

        --now check the 'empty' flag and if the folder is the root
        if empty and path ~= root then
            c_RemoveFileDir( path )
        end
    end

    walk( root )
 end