I am working on a python script to open a file with a Unicode name (mostly Japanese) and save in a randomly generated (non-Unicode) file name on a 64-bit version of Windows Vista, and I'm having problems ... It just doesn't work, it works great with file names other than unicode (even if it has unicode content), but the second you try to pass the file name to unicode - this does not work.
Here is the code:
try:
import sys, os
inpath = sys.argv[1]
outpath = sys.argv[2]
filein = open(inpath, "rb")
contents = filein.read()
fileSave = open(outpath, "wb")
fileSave.write(contents)
fileSave.close()
testfile = open(outpath + '.test', 'wb')
testfile.write(inpath)
testfile.close()
except:
errlog = open('G:\\log.txt', 'w')
errlog.write(str(sys.exc_info()))
errlog.close()
And the error:
(<type 'exceptions.IOError'>, IOError(2, 'No such file or directory'), <traceback object at 0x01092A30>)
source
share