At Wednesday 26/7/2006 16:33, Ahmed, Shakir wrote:

I am trying to change the file permission for all of the files in a
directory but getting errno 2, the code is as follows, any help is
highly appreciated. I am using pythonwin version 2.1



permission.py

for fl in os.listdir("V:\\data\\tst\\mdb"):


    import os


    def unicode_test(fl):
        try:
            f = file(fl, 'w')
            f.close()
        except IOError, e:
            print e
            return
    try:
        os.chmod(fl, -0777)
    except OSError, e:
        print e


====
The error I am getting :

>>> [Errno 2] No such file or directory: 'gend_taskstatus.mdb'
[Errno 2] No such file or directory: 'str.mdb'

os.listdir() returns the names *without* path. Use os.path.join to join path+name. -0777 looks like Unix permission bits (negative?), but a path with \\ is strange...
The enclosed function unicode_test is useless.
And, the import statement usually is located at the top of the module.



Gabriel Genellina
Softlab SRL

        
        
                
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to