Added default for directory to take  parameter as they're often the same thing, and cleaned the spoolfile from the name to remove slashes