- Code: Select all
for dirFile in os.listdir(currentFolder):
try:
#pulls the format type out of the file
fileFormat = dirFile[dirFile.index(".")+1:]
#moves the file to it's new destination
#shutil.move(currentFolder+slash+dirFile, currentFolder+slash+formatArray[fileFormat])
print currentFolder+slash+formatArray[fileFormat]+slash+"Broken part"
except ValueError:
pass
except KeyError:
logFile.write(timeStamp()+"Unknown file format "+fileFormat+" add to "+sourceFile+" to fix"+"\n")
except shutil.Error:
logFile.write(timeStamp()+"Can not move file "+dirFile+"\n")
Results:
Expected:/media/usbstick/music/Broken part
Obtained:/Broken partick/music
This is a problem cause I can't transfer files without them screwing up.