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'

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

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

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..

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..

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

The  ” Long Path Tool ” is also useful in situations where you see these error messages

Use Long Path Tool, Long Path Tool can simplify and probably end your problems in unlocking, managing and renaming files that appear to have a long filename.

commented: Please stop spamming -3
commented: Just replicates previous post 4 months later. Pathetic -3

Yeah hi, it can hurt bad
Save yo' tears bro' and give LongPath Tool Program a go !

commented: duplicates previous post and is 16 years too late +0
commented: Duplicated above and 16 years late. +0

Why are you both saying that he has just duplicated a previous post? I cannot find a previous post that mentions LongPath tool?

(Moderator's note: There actually was a post recommending it 13 years ago, but happygeek deleted it back then for being spammy. He probably shouldn't have done so, since someone else is now recommending that same very tool all these years later.)

commented: So far any note about longpath tool is spam. At one time it was MALWARE. Could be still. +17

What about eden100 who 8 years ago posted

Use Long Path Tool, Long Path Tool can simplify and probably end your problems in unlocking, managing and renaming files that appear to have a long filename.

Oh, I missed that one. Wasn't 16 years ago though?

Correct. It was a typo. Should have said "15 years too late" because that was when the question was first posted. I have noticed a number of new posts in old threads that essentially just rephrase (sometimes with only very minor changes) previous posts. There is no Daniweb rule against doing this but I think it is worth a comment and a down-vote.

commented: Recommending what was possible malware should be a rule breaker. +17
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.