PCEVA,PC绝对领域,探寻真正的电脑知识
打印 上一主题 下一主题
开启左侧

对于超长路径超长文件名不能复制粘贴的问题怎么解决?

[复制链接]
跳转到指定楼层
1#
673 发表于 2012-4-9 07:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
点击数:54576|回复数:27
我现在用的是win7,有时候会遇到超长文件名在超长路径下不能正确复制粘贴的问题,系统会提示你缩短文件名然后再复制粘贴。为什么会有这种情况呢?难道是win7的局限性?有没有什么备份软件可以解决这个问题的?我不想改动我的文件名,而且我试过就算把文件拷到较短路径再复制到那个超长路径系统也会自动将你的文件名缩短。
2#
gmx168 发表于 2012-4-9 11:25 | 只看该作者
http://windows.microsoft.com/en- ... tly-asked-questions

What is the maximum length of a file name?
Windows usually limits file names to 260 characters. But the file name must actually be shorter than that, since the complete path (such as C:\Program Files\filename.txt) is included in this character count. This is why you might occasionally encounter an error when copying a file with a very long file name to a location that has a longer path than its current location.

简单的说,Windows的目录架构限制文件名的最大长度为260个字符,这不单单是对文件名字本身长度的限制,也包括了绝对路径的长度限制。也就是说,一个文件名的长度加上路径的长度不能超过260个字符。

不仅仅是Win7如此,XP等等支持8.3格式之外的长文件名系统都是如此。
3#
James007ss 发表于 2012-4-9 12:08 | 只看该作者
gmx168 发表于 2012-4-9 11:25
http://windows.microsoft.com/en-US/windows-vista/File-names-and-file-name-extensions-frequently-aske ...

我也想请教下老黄,BT下时路径下回来没问题,播放什么的也没问题,但复制时却出问题,这是什么原因呢?例如同样的目录里有高清影片了,绝对路径超长的,但同样文件名的外挂字幕文件复制进这个文件夹就会提示出错。
4#
gmx168 发表于 2012-4-9 15:31 | 只看该作者
James007ss 发表于 2012-4-9 12:08
我也想请教下老黄,BT下时路径下回来没问题,播放什么的也没问题,但复制时却出问题,这是什么原因呢?例 ...

你这个问题问得很好,因为我也碰到过,一直没有好好研究过。

那么我们现在研究一下吧~~~~解铃还需系铃人,老规矩,找微软~~~

搜到这么一篇微软官方的文章,不错,应该可以解决我们的困惑
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

以下是从文章中摘录出来的一段:
Maximum Path Length Limitation
In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string<NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

Note  File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections.

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path".Note  The maximum path of 32,767 characters is approximate, because the "\\?\" prefix may be expanded to a longer string by the system at run time, and this expansion applies to the total length.

The "\\?\" prefix can also be used with paths constructed according to the universal naming convention (UNC). To specify such a path using UNC, use the "\\?\UNC\" prefix. For example, "\\?\UNC\server\share", where "server" is the name of the computer and "share" is the name of the shared folder. These prefixes are not used as part of the path itself. They indicate that the path should be passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory, or double dots to represent the parent directory. Because you cannot use the "\\?\" prefix with a relative path, relative paths are always limited to a total of MAX_PATH characters.

There is no need to perform any Unicode normalization on path and file name strings for use by the Windows file I/O API functions because the file system treats path and file names as an opaque sequence of WCHARs. Any normalization that your application requires should be performed with this in mind, external of any calls to related Windows file I/O API functions.

When using an API to create a directory, the specified path cannot be so long that you cannot append an 8.3 file name (that is, the directory name cannot exceed MAX_PATH minus 12).

The shell and the file system have different requirements. It is possible to create a path with the Windows API that the shell user interface is not able to interpret properly.
5#
gmx168 发表于 2012-4-9 15:37 | 只看该作者
意思就是说,微软的平台上的应用程序可以超出常规的260字符限制而达到32767这样的路径长度,是否支持要看不同的程序。这种超长格式也有一些限制,就是它使用反斜杠\来分割路径,每个路径最大长度为255,这些路径全长加上文件名长度不得超过32767字符。


The shell and the file system have different requirements. It is possible to create a path with the Windows API that the shell user interface is not able to interpret properly.
这句话的意思是说:Windows应用程序创建的路径未必一定能被用户界面的Shell的命令正确识别。
6#
gmx168 发表于 2012-4-9 15:44 | 只看该作者
为此,我做了一个测试



蓝色框下的目录是我在Windows Explorer下手工一层层建立的,2011 B后面的字符在黏贴后被自动删减了,这个路径总长应该不超过260,我没数,相信应该是的。

再看红色框,这个是通过BT(uTorrent)软件建立的,这个路径长度明显超出了260字符,说明了什么?UTorrent这样的Windows应用程序使用了扩展的长度限制(extended-length )。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
7#
James007ss 发表于 2012-4-9 15:46 | 只看该作者
本帖最后由 James007ss 于 2012-4-9 15:47 编辑
gmx168 发表于 2012-4-9 15:37
意思就是说,微软的平台上的应用程序可以超出常规的260字符限制而达到32767这样的路径长度,是否支持要看不 ...


该死的MS,人工和自动还给鼓捣出2套标准啊....

对头,PT站下的高清都是UT下的。
8#
gmx168 发表于 2012-4-9 15:47 | 只看该作者
总结一下:
Windows下有些程序支持最大路径长度为32767,而有些却只支持到260,这样的不同标准是造成我们困惑的根本原因。
9#
gmx168 发表于 2012-4-9 15:49 | 只看该作者
James007ss 发表于 2012-4-9 15:46
该死的MS,人工和自动还给鼓捣出2套标准啊....

对头,PT站下的高清都是UT下的。 ...

10#
James007ss 发表于 2012-4-9 15:59 | 只看该作者
晚点研究下用ROBOCOPY的话,是哪个标准才行。
11#
我叫Jonn.yR 发表于 2012-4-9 16:18 | 只看该作者
只接全部超长路径长度能怎么着?微软小气了。
12#
gmx168 发表于 2012-4-9 16:21 | 只看该作者
据传,Win8应该突破了260的限制,有Win8的可以帮忙测试一下
13#
zhujunsan 发表于 2012-4-10 04:16 | 只看该作者

表示好像Win8跟Win7也是一样的

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
14#
673  楼主| 发表于 2012-4-10 04:47 | 只看该作者
James007ss 发表于 2012-4-9 02:59
晚点研究下用ROBOCOPY的话,是哪个标准才行。

搜索了一下你说的这个文件,发现是一个高级的复制粘贴软件。但我想要一个可以实现增量备份的软件啊(主要是备份笔记上的数据用),不知道acrnois可不可以。
15#
673  楼主| 发表于 2012-4-10 04:47 | 只看该作者
zhujunsan 发表于 2012-4-9 15:16
表示好像Win8跟Win7也是一样的

希望这只是beta版才有的情况。
16#
gmx168 发表于 2012-4-10 09:52 | 只看该作者
673 发表于 2012-4-10 04:47
搜索了一下你说的这个文件,发现是一个高级的复制粘贴软件。但我想要一个可以实现增量备份的软件啊(主要 ...


如果不想改文件名,还有个办法就是用压缩软件。

要备份的也就是那么几个文件夹,不要太纠结了。
17#
James007ss 发表于 2012-4-10 14:12 | 只看该作者
673 发表于 2012-4-10 04:47
搜索了一下你说的这个文件,发现是一个高级的复制粘贴软件。但我想要一个可以实现增量备份的软件啊(主要 ...

ROBOCOPY不是备份,也不算什么高级复制软件,它其实就是WIN的高级复制命令而已(通常命令行运行),你找到的可能是老外做的GUI壳,有收费有免费的,我的意思其实是看看能否利用它把图形界面下复制不了的文件复制到我需要的位置,你要备份的话,是要看看ATIH本身是否支持这个超长地址的标准才行。
18#
673  楼主| 发表于 2012-4-11 02:35 | 只看该作者
James007ss 发表于 2012-4-10 01:12
ROBOCOPY不是备份,也不算什么高级复制软件,它其实就是WIN的高级复制命令而已(通常命令行运行),你找 ...

嗯,我明白你的意思,你说的我都知道的。
19#
whgp05 发表于 2012-5-1 00:22 | 只看该作者
可以试试这个办法。如果原始路径和文件名太长,例如C:\1\12\123\1234\12345\123456\1234567.XXX无法复制,可尝试将最后一级文件夹复制至根目录,即将123456\1234567.XXX复制到C:\
20#
673  楼主| 发表于 2012-5-1 00:37 | 只看该作者
whgp05 发表于 2012-4-30 11:22
可以试试这个办法。如果原始路径和文件名太长,例如C:\1\12\123\1234\12345\123456\1234567.XXX无法复制,可 ...

试过的,根目录是可以但要放回原处还是会自动缩减文件名,这点我前面已经提到。
而且我现在想要的是一款功能强大的备份软件,我想应该有某种软件可以复制长一点的文件名。但苦于网上此类软件太多,不知道选哪个好。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部