Fixed script to work with paths that contain special characters