I have a folder that is synchronized by this CLI command:
aws.exe s3 sync "s3 bucket" "folder"
The Windows CLI version is 1.2.11. The "folder" is in a Windows7 NTFS file system. I think that there is a problem with long path name because I obtain this error when syncing (sorry, my windows is in italian):
[Error 3] Impossibile trovare il percorso specificato: u'C:\Users\Server\Documents\Server.........................
The path that is searched is 268 characters. If I rename the file and obtain a path name length less than 256 characters, s3 sync works properly. Can be the problem related to Maximum Path Length Limitation as explained here?
http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
I believe you're correct, thit is related to the maximum path length limitation. In python I can't even create a file with more than 260 chars (I'm using 260 - length("c:\temp\")
for the lengths below):
>>> open('a' * 251, 'w').close()
>>> open('a' * 252, 'w').close()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
In this situation I'm not really sure there's much we can do. Even in powershell trying to run touch 260charfilename...
doesn't work. This seems like a windows limitation so I'm not sure there's anything we can do to fix this issue, though I'd be open to suggestions.
In effect it's a Windows limit and other documentation confirms this (http://windows.microsoft.com/en-us/windows/file-names-extensions-faq#1TC=windows-7). But Windows has a strange behaviour because it allows you to write file with more than 260 characters also with Explorer (my customer turns out in this way). For example, you create a folder with this name C:\Temp\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccc
, then a subfolder with this name dddddddddddddddddddddddddddddddddddddddddd
and inside it a file with this name eeeeeeeeee.txt
. Than you rename the subfolder adding ffffffffffff
and its parent folder adding ggggggg
(please, in this order): in this way you obtain this path name C:\Temp\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccffffffffffff\ddddddddddddddddddddddddddddddddddddddddddggggggg\eeeeeeeeee.txt
that is 275 characters long!
With this java code I write path name with 477 characters (I could test this code only in windows 8.1):
String filename = "c:\\temp\\" + new String(new char[254]).replace("\0", "a") + "\\" + new String(new char[205]).replace("\0", "b") + "\\test.txt";
System.out.println("Filename length: " + filename.length());
FileOutputStream fw = null;
try {
File f = new File(filename);
if (!f.getParentFile().exists())
f.getParentFile().mkdirs();
fw = new FileOutputStream(f);
fw.write("Test file".getBytes());
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fw != null) {
fw.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
Have you tried writing the file with long path support prefix "\?\" ? See here if useful http://bugs.python.org/issue18199
Sorry to bring an old issue up,
What about using/trying \\?\
in case of File does not exist.
I'm second this request. Long File Paths FTW!
Maybe this SO answer gives more details on @nwohaibi's suggestion.
Most helpful comment
Sorry to bring an old issue up,
What about using/trying
\\?\
in case ofFile does not exist.