long paths problem in windows

70 views
Skip to first unread message

Mahmoodreza Aarabi

unread,
Feb 7, 2016, 12:57:40 AM2/7/16
to Python Programming for Autodesk Maya
Hello to all

I have a problem that probabely you faced with it, in windows when we copy a file from a source and paste it in a long path (i mean a deep path) it does not paste.
Or if you have a long path and you want to create a simple text file in it you can just write some words in its name.

I had some recearch about it and i find that we just can have a path+filename with maximum 244 character.
Now problem is that when we want to open a file in maya that is in the end of a long path that its address is more than 244 characters, maya will crash.

There is any way that we can remove this limitation with python? because at the end of R&D i need to implement it with python, and i don't want to be worried about the lenght of the path.

Example:
D:\path\to\the\project\of\testingPathOfFolders\firstFolder\subfolder1\subfolder2\subfolder3\subfolder4\this\path\is\very\very\long\path\and\it\will\create\problem\for\reading\and\writing\such\maya\files\like\project_modeling_filename_author_date_test.ma

[253] character in this path (just a  dummy example)

thanks

Justin Israel

unread,
Feb 7, 2016, 2:26:59 AM2/7/16
to Python Programming for Autodesk Maya

I haven't dealt with this problem, but some quick searching turned up a kind of "extended" path notation :
https://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath

Something like:
\\?\D:\path\...

Does this actually work?

Justin


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/eb7ffc19-616d-48fa-b14d-12327f40bfd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mahmoodreza Aarabi

unread,
Feb 7, 2016, 4:02:04 AM2/7/16
to python_in...@googlegroups.com
Thank you Justin
i had some research on this
yes, it works in creating nested deep folders with python and directory with any length will create with it, but in windows does not open the end folder when we use the path.

and in maya we can't save file more than 260 character but interesting point is that when i want to open the saved file (saved in the middle of path) maya crashes :)

my question here is that based on your experiences, directory structure in studios is long when an artist want to access to a file with different department and works?

thanks


For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Marcus Ottosson

unread,
Feb 7, 2016, 4:40:45 AM2/7/16
to python_in...@googlegroups.com

Sadly, one cannot make use of paths longer than 256 characters on the Windows platform. :(

You might be able to work around it in specific scenarios, but as you have discovered, there may be other scenarios that might not work and where a solution is out of your control; such as in Maya. What I’ve found is that most applications do not support extended paths and have since given up trying to find a way to work with it proper.

As a workaround, you can try:

a) Create a junction from a deeply nested path. For example, if your path is c:\long\path\to\file.jpg, then create a junction from c:\long\path to c:\short and you will be able to reach your file at c:\short\to\file.jpg. Or..

b) Share the same point within the directory and map it to a drive letter; such as z:\.

But in general, I would avoid ever getting to such lengths if possible.



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Justin Israel

unread,
Feb 7, 2016, 1:46:13 PM2/7/16
to python_in...@googlegroups.com


On Sun, 7 Feb 2016 10:02 PM Mahmoodreza Aarabi <mado...@gmail.com> wrote:
Thank you Justin
i had some research on this
yes, it works in creating nested deep folders with python and directory with any length will create with it, but in windows does not open the end folder when we use the path.

and in maya we can't save file more than 260 character but interesting point is that when i want to open the saved file (saved in the middle of path) maya crashes :)

my question here is that based on your experiences, directory structure in studios is long when an artist want to access to a file with different department and works?

This specific small limitation is windows based, and the studios I worked for use Linux or OSX. So I haven't hit a path max or filename max problem yet. 
I've seen some generic code that tries to account for windows compatibility by using chdir as it traverses the filesystem, so that it can always refer to paths with a shorter relative name. Does that help at all? Might not help in all cases of Maya though. But in scripts it might? 

Mahmoodreza Aarabi

unread,
Feb 7, 2016, 2:20:12 PM2/7/16
to python_in...@googlegroups.com
Yes man. it was helpfull. now i have to use windows.
I try to use relative Paths
Btw, thanks.
:)


For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Mahmoodreza Aarabi

unread,
Feb 8, 2016, 8:19:28 AM2/8/16
to python_in...@googlegroups.com
Hey justin
i created my path with "\\?\D:\path\" that you said.
do you believe that it is not remove now? with any permission!!!
:D
--


Bests,
madoodia

Justin Israel

unread,
Feb 8, 2016, 1:17:40 PM2/8/16
to python_in...@googlegroups.com

Sing a song with me everyone! "Weeeee looooove Windows!"


Paul Molodowitch

unread,
Feb 8, 2016, 2:12:29 PM2/8/16
to python_in...@googlegroups.com
Yeah, that 260 char path limit on windows sucks.  I can't believe they still have that. Windows isn't one of our core platforms here, though, so the couple times I've had to deal with this, I've gotten by with a combination of the long path syntax mentioned above (the  "\\?\D:\path\"  stuff) and judiciously created directory junctions - the issue being that you can use the long paths for certain specific tasks, but most other programs won't be able to use them, so I make directory junctions (window's version of symlinks) to create "shorter" versions of the paths that I can use in various GUIs (including the windows file browser, I think) / other APIs.

I wouldn't want to base any long-term pipe code around that sort of solution though...

Mahmoodreza Aarabi

unread,
Feb 9, 2016, 12:54:30 AM2/9/16
to python_in...@googlegroups.com
Haha, Shame on windows
any way i removed it with 7zip but it is so wiered

Thank Paul


For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia
Reply all
Reply to author
Forward
0 new messages