tags:

views:

142

answers:

3

Hi,

I write Python script to copy files; unfortunately it keeps failing because filename is too long(>256). Is there anyway to deal with that problem?

I'm using Python 2.5.4 and Windows XP.

Cheers,

+3  A: 

Use paths beginning with the string \\?\.

bcat
Thanks bcat! I got it working now.
Sophy
A: 

Have you tried the workarounds suggested in this old thread, exp. the "magic prefix" trick? I don't know if the underyling issue (that we're not using the right one out of the many available Windows APIs for files) ever got fixed, but the workarounds should work...

Alex Martelli
+3  A: 

In order to use the \\?\ prefix (as already proposed), you also need to make sure you use Unicode strings as filenames, not regular (byte) strings.

Martin v. Löwis
Oh, I didn't know that. Thanks!
bcat
Thanks Martin! I got it working now.
Sophy