Re: Problem with os.chdir()



Hello,

In order to prevent this type of problems, I alway do the following:

import path

path = something
path = os.path.normpath(path)
os.chdir(path)

This prevents a lot of problems for me.

Regards,
Henk

"Tim Golden" <mail@xxxxxxxxxxxxxxx> wrote in message
news:mailman.1646.1236751732.11746.python-list@xxxxxxxxxxxxx
venutaurus539@xxxxxxxxx wrote:
Hello all,
I am writing a python script which has to access deep paths
then supported normally by the Windows OS (>255). So I am appending "\
\?\" to do so. But when I use the path in the above fashion with
os.chdir() it is unable to recognize my folder and throwing an error:

Traceback (most recent call last):
File "C:\JPDump\test.py", line 31, in <module>
renameStubs(file)
File "C:\JPDump\test.py", line 15, in renameStubs
os.chdir (path)
WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: '\\?\\C:\\TestDataSet\
\Many_Files_10000_1KB_FIles\\001_0009_1000 FILES\\'

The value of my path variable is
\?\C:\TestDataSet\Many_Files_10000_1KB_FIles\001_0009_1000 FILES\


There need to be two backslashes at the beginning:

\\?\C:\TEST.....FILES\

Note the double backslash before the question mark.

TJG


.


Quantcast