Refactor scripts to take either a file or a directory as arguments.