help with file path exceeding 255 characters

yguan08 at gmail.com yguan08 at gmail.com
Tue May 13 16:27:09 EDT 2008


I have trouble of obtaining the file size of a file because the
fullpath exceeds 255 characters. I get this message with
os.path.getsize(fullpath).

fullpath = r"\\LOSSSFS002\NWE_TECHNICAL\05. UK\Schiehallion (204_25a)
\Amos&Burke_P559\07. Technical (Subsurface)\06. Well Planning\Amos
\Daily Reports\Wireline\final_204_25a_8z\204_25a_8z\Run_1A
\HRLA_SP_DSI_PEX_HNGS_ECRD\ANCILLARY\Amos_204_25a-8Z_GR_to_surface_3-
Mar-2008_DSI_HRLA_TLD_MCFL_047PUC.las"

fsize = os.path.getsize(fullpath)


WindowsError: [Error 206] The filename or extension is too long:

The same thing with os.stat(fullpath).

I tried using the relative path, but it does not work with the message
fname not found.

dir = os.path.dirname(fullpath)
fname = os.path.basename(fullpath)
os.chdir(dir)
filesize = os.path.getsize(fname)

Is there a walk around of this?



More information about the Python-list mailing list