Found a bug that when the initial file list would not contain the root folder, the script would fail.