[Pythonmac-SIG] how to delete files which special characters on Mac OS 10.3

Dr. L. Humbert humbert at semsek2.ham.nw.schule.de
Mon Jan 12 15:41:38 EST 2004


Hi,
I have to write a Python-script to delete files on Mac OS 10.3.
When I found out, that my cron-job 
    updatedb
stops at special filenames (for example) 
'SIIHamm,G\xed\xb6\x86\xed\xbb\xa9chu.a.rtf'
I wanted to delete those files with the finder (via trash),
but I had no success.
    error -43
Ok, so I decided to open a terminal and tried
    rm -rf *
in the directory, where those files "live".
But -- it did'nt work.

[ddi-balzac:~/MUELL/Dreck/1] hum% ls -l
ls: SIIHamm,Gí¶í»©chu.a.rtf: No such file or directory
ls: SIIMíµ¶í²¨engladbach,Kleinu.a.doc: No such file or directory

Now I want to solve the problem via a python-script:
Here it goes:

>>> dels=os.listdir(".")
>>> dels
['SIIHamm,G\xed\xb6\x86\xed\xbb\xa9chu.a.rtf', 
'SIIM\xed\xb5\xb6\xed\xb2\xa8engladbach,Kleinu.a.doc']

>>> for i in dels:
...     os.remove("./"+i)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in ?
OSError: [Errno 2] No such file or directory: 
'./SIIHamm,G\xed\xb6\x86\xed\xbb\xa9chu.a.rtf'

Whats going on here?

If I look at those files in the finder, I see two symbols between
G and c
SIIHamm,G__chu.a.rtf

How is it possible to delete those files from a python-script?

	L. Humbert
-- 
Dr. L. Humbert <humbert at semsek2.ham.nw.schule.de>

http://semsek2.ham.nw.schule.de/Ausbildung/Fachseminare/
Studienseminar Hamm - Fachseminar Informatik

Python 2.3.3 (#2, Jan  4 2004, 12:24:16)
>>> print 'RGFzIGlzdCBlaW4gc2No9m5lciBUYWcgLi4u\n'.decode("base64")




More information about the Pythonmac-SIG mailing list