File was be put to incorrect place when the firstFolderName is same as lastFolderName in the path

If the first and last folder name is same in the entry path (For example: folder1234/otherFolder/folder1234/test.txt), then the file will be put to first folderfolder1234