spaces at ends of filenames or directory names on Win32
rtilley
rtilley at vt.edu
Thu Feb 23 13:20:36 EST 2006
# Spaces are present before and after the XXX
filename = ' XXX '
new_filename = filename.strip()
if new_filename != filename:
print filename
Macs allow these spaces in file and folder names. Which is OK. The
problem arises when the file or folder is copied to a PC running Windows
from a Mac. Windows allows the Mac to copy the file to it, but when
Windows itself attempts to do anything with the file it strips the
spaces and then tries to move it, copy it, etc and complains that the
file isn't there!
I can rectify this by striping the spaces from the files and folders on
the Mac before they are copied to the PC or mounting the Windows share
from the Mac and running a recursive strip program I wrote, but Windows
will not allow the whitespace removal directly from within Windows....
how annoying!
For example... tell windows to move a file named ' XXX ' (one space
before and one space after the filename). Windows will complain that
file 'XXX' does not exist. It's correct of course, 'XXX' does not exist,
but ' XXX ' does indeed exist.
Can anyone rescue me from this madness :(
Many Thanks,
Brad
More information about the Python-list
mailing list