A python script I use to backup files on a Windows 2003 server
occasionally fails to retrieve the size of a file with a question mark
in the name. The exception I get is "OSError #123 The filename,
directory name, or volume label syntax is incorrect". I realize that
technically a question mark in the name of a file on Windows is
illegal, but nevertheless these files exist on the file system. It
seems that they are created by Office 2007 Word, for the most part.
The line that fails is:
Where source is the full path to the file with the question mark in
Any idea how to retrieve the file's size? Also, I imagine that after I
overcome this hurdle, I'll need help finding a way to copy the file
(assuming copy2() doesn't work). I've tried escaping the question mark
("\\?"). Same result.
Although I could use the Windows "dir" command, parsing the results to
find the size of the file then use the Windows "copy" command, I'd
rather stay away from this type of solution.
Any help is appreciated!