[SOLVED]: Copying a file with a question mark in it's name in Windows

drodrig drodrig at magicbrain.com
Tue Aug 17 14:03:05 EDT 2010


On Aug 12, 9:16 am, Aleksey <alekse... at gmail.com> wrote:
> On 12 авг, 18:49,drodrig<drod... at magicbrain.com> wrote:
>
> > 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.
(Sorry for the late reply)

Thank you. The questions marks are indeed placeholders for unprintable
characters. The glob module did the trick.

>
> If "?" is a placeholder for an unprintable character you can try view
> real file name in IDLE:
>
>   import glob
>   print glob.glob(u'e:/full/path/to/file?')
>
> In path to file you must instead question use wild "?".
> Will be printed all like files.
>
> -----------------------------
> Under Windows I too have similar problem: windows sometimes (from any
> programs - e.g. Firefox) save files with wrong names, but later
> do not manipulate with it.




More information about the Python-list mailing list