1,105,578 Community Members

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

Member Avatar
kamaksha1
Newbie Poster
3 posts since Nov 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi.. I've to remove a very long path. I've written the below to try that but its giving WindowsError: [Error 206] (I've pasted it below). I've prepended "\\?\" to the actual path but still I'm getting the exception. Please let me know the solution...
++++
import os
import shutil

os.rmdir(os.path.realpath(r"\\?\D:\Kamesh\test-1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950\test-1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950\kkkkkkkkkkkkkkkkkkkkkkkkk\kllkppppppppppppp\long_path_test"))
++++++++++++++++


++++++++++
WindowsError: [Error 206] The filename or extension is too long: '\\\\?\\D:\\Kam
esh\\test-1234567891011121314151617181920212223242526272829303132333435363738394
041424344454647484950\\test-1234567891011121314151617181920212223242526272829303
132333435363738394041424344454647484950\\kkkkkkkkkkkkkkkkkkkkkkkkk\\kllkpppppppp
ppppp\\long_path_test'

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
0
 

Are you trying to store your data in the file path?
Please read the Windows manual on file path limitations.

Member Avatar
jbennet
Moderator
17,127 posts since Apr 2005
Reputation Points: 1,618 [?]
Q&As Helped to Solve: 736 [?]
Skill Endorsements: 38 [?]
Team Colleague
Featured
 
0
 

Path cannot be more than 255 chars on NT based systems using NTFS

Member Avatar
kamaksha1
Newbie Poster
3 posts since Nov 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Are you trying to store your data in the file path?
Please read the Windows manual on file path limitations.

Thanks for your valuable suggestion.

I have to remove too long path created by some scripts of our project... I've just taken an example to try it out. Please don't validate the path given in the example and that is not the data as you assumed...

I did search in google but couldn't find the exact solution..
just let me know the solution if you have any solution..

Member Avatar
kamaksha1
Newbie Poster
3 posts since Nov 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Path cannot be more than 255 chars on NT based systems using NTFS

Yeah.. you are right.. in some cases where the path exceeds 255 chars, we can prepend '//?/' so that it allows around 3000 chars and then we can remove it.. but still i think i've missed something in the script..

Member Avatar
Markovin
Newbie Poster
2 posts since Oct 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Well, I got the same problem as very annoying and with no explanation as the file names have no visible illegal characters and are not too long and not copied or deleted and found good stuff at http://pathtoodeep.com/ and also over here. Thanks

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article