Thanks comp.lang.python!!!

hokiegal99 hokiegal99 at
Sun Jul 20 05:40:05 CEST 2003

While migrating a lot of Mac OS9 machines to PCs, we encountered several 
problems with Mac file and directory names. Below is a list of the problems:

1. Macs allow characters in file and dir names that are not acceptable 
on PCs. Specifically this set of characters [*<>?\|/]

2. Mac files and dirs that contained a "/" in their names would ftp to 
the server OK, but the "/" would be translated to "%2f". So, a Mac file 
named 7/19/03 would ftp as 7%2f19%2f03... not a very desirable filename, 
especially when there are hundreds of them.

3. The last problem was spaces at the beginning and ending of file and 
dir names. We encountered hundreds of files and dirs like this on the 
Macs. They would ftp up to the Linux server OK but when the Windows PC 
attempted to d/l them, the ftp transaction would stop and complain about 
not finding files whenever it tried to transfer a file. Dirs with spaces 
at the beginning or ending would literally crash the ftp client.

These were problems that we did not expect. So, we wrote a script to 
clean up these names. Since all of the files were bring uploaded to a 
Linux ftp server, we decided to do the cleaning there. Python is a 
simple, easily readable programming language, so we chose to use it. 
Long story short, attached to this email is the script. If anyone can 
use it to address Mac to PC migrations, feel free to.

The only caveat is that the script uses os.walk. I don't think Python 
2.2.x comes with os.walk. To address this, we d/l 2.3b2 and have used it 
extensively with this script w/o any problems. And, someone here on 
comp.lang.python told me that os.walk could be incorporated into 2.2.x 
too, but I never tried to do that as 2.3b2 worked just fine.

Thanks to everyone who contributed to this script. Much of it is 
straight from advice that I received here. Also, if anyone sees how it 
can be improved, let me know. For now, I'm satisfied with it as it works 
"well enough" for what I need it to do, however, I'm trying to become a 
better programmer so I appreciated feedback from those who are much more 
experienced than I am.

Special Thanks to Andy Jewell, Bengt Richter and Ethan Mindlace Fremen 
as they wrote much of the code initially and gave a lot of great tips!!!
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fix_names-1.0.1py
URL: <>

More information about the Python-list mailing list