before line 123 ish
renameFile(currentAttachmentPath, newAttachmentPath)
throw in a print function to get the above input parameters to check them.
whatever you are passing in to the paths seems to be a list. This might mean there is only one object in the list and you want the first object, but what it is looking for is basically a text string which denotes the full pathname, and it is getting a list instead