如何删除文件Windows声明“太长”

If you’ve run into a problem deleting a file that Windows complains is “too long”, there is a dead simple solution built right into Windows—no extra apps, hacks, or work around required.

如果您遇到了删除Windows抱怨的文件“太长”的问题,则Windows内置了一个死的简单解决方案-不需要额外的应用程序,黑客或变通办法。

“太长”的名称有什么关系? (What’s the Deal with “Too Long” Names?)

We’ve talked about this in greater detail before, but here’s the gist: Windows uses a naming convention called “Long Filenames (LFN)”. The LFN system supports file names up to 255 characters. Other operating systems, however, do not have similar restrictions. So if some Mac or Linux user were to archive a bunch of files with longer names and send you the archive, extracting that archive would leave you with files that exceed Windows’ character length. If you try to delete one of them, Windows will report that the name of the file is too long and it cannot delete it.

之前 ,我们已经详细讨论了这一点 ,但要点是:Windows使用一种称为“长文件名(LFN)”的命名约定。 LFN系统支持最多255个字符的文件名。 但是,其他操作系统没有类似的限制。 因此,如果某些Mac或Linux用户要归档一堆名称较长的文件并将其发送给您,则解压缩该归档文件将使您留下的文件长度超过Windows字符长度。 如果您尝试删除其中之一,则Windows将报告该文件名太长,无法将其删除。

There’s a variety of ways you can deal with this problem (like downloading the free 7-Zip file compression tool, whose built-in file manager doesn’t complain about file name length), but rather than resort to extra software or third-party workarounds, we can leverage an old Windows trick to make short work of the files.

您可以通过多种方式来解决此问题(例如下载免费的7-Zip文件压缩工具,该工具的内置文件管理器不会抱怨文件名的长度),而不是求助于其他软件或第三方解决方法,我们可以利用旧的Windows技巧来简化文件工作。

If you’re having trouble with long file path names, rather than long file names, you can make a small tweak in Windows 10 that enables longer file paths, too.

如果您在使用长文件路径名而不是长文件名时遇到麻烦,则可以在Windows 10中进行一些小的调整,以启用更长的文件路径。

删除长文件的最简单方法 (The Simplest Way to Delete Long Files)

Before the Long Filename system there was the filename system in DOS, now known as the 8.3 Filename system (on account of the filenames being limited to 8 characters with a 3 character extension). Windows is famed for being backwards compatible, and this is a perfect example of where that backwards compatibility is extremely useful. Decades after DOS was a major operating system, we can still call up the DOS filenames for files on our modern Windows computers and, unlike the too-long-file-names that upset it, Windows won’t complain a bit when working with those short file names (even though they point at the same exact files that caused the problem in the first place).

在长文件名系统之前,DOS中有一个文件名系统,现在称为8.3文件名系统(由于文件名限制为8个字符,扩展名为3个字符)。 Windows以向后兼容而闻名,这是向后兼容极其有用的完美示例。 在DOS成为主要操作系统数十年之后,我们仍然可以为现代Windows计算机上的文件调用DOS文件名,与使文件名过长的文件名不同,Windows在处理这些文件时不会抱怨短文件名(即使它们指向的是引起问题的相同文件)。

In order to delete a too-long-file, all you need to do is open a command prompt in the directory where the file is located and use a simple command to get the short file name. Open File Explorer and navigate to the directory where your files are located. Press and hold Shift, then right-click on an empty area. Choose “Open command window here”. A Command Prompt window will open, focused on the directory you’re in.

为了删除太长的文件,您需要做的就是在文件所在的目录中打开命令提示符,然后使用简单的命令来获取短文件名。 打开文件资源管理器,然后导航到文件所在的目录。 按住Shift,然后右键单击空白区域。 选择“此处打开命令窗口”。 将打开一个命令提示符窗口,重点放在您所在的目录中。

pasted_image_at_2016_12_09_10_05_am

Then, enter the following command in the Command Prompt window:

然后,在“命令提示符”窗口中输入以下命令:

DIR /X

If the directory contains more files than can be displayed on a single screen, use the command DIR /X /P instead, so that it will pause at every screen length so you can examine the file list.

如果目录包含的文件多于单个屏幕上可以显示的文件,请改用命令DIR /X /P ,这样它将在每个屏幕长度处暂停,以便您检查文件列表。

This command will list all the directories and files in the current directory, and it will also list the old 8.3 filename for all the files and directories. In our example screenshot above, you can see how the dummy txt file with nonsensical (and hundreds of characters long) filename is reduced to a simple “WHYSOL~1.TXT”.

此命令将列出所有的目录和文件在当前目录中也列出旧的8.3文件名的所有文件和目录。 在上面的示例屏幕截图中,您可以看到具有无意义(长数百个字符)文件名的虚拟txt文件如何减少为简单的“ WHYSOL〜1.TXT”。

Armed with the short name of the file or directory you wish to delete, you can simply issue a DEL command for the file:

有了要删除的文件或目录的简称,您只需为该文件发出DEL命令:

DEL WHYSOL~1.TXT

Obviously, replace WHYSOL~1.TXT  with the name of the file you want to delete.

显然,将WHYSOL~1.TXT替换为您要删除的文件的名称。

Windows will delete the file without complaint (you can run DIR /X again to confirm or just check the directory in Window Explorer). That’s all there is to it! With a clever use of a very old command, you can delete any file regardless of how long the file name is.

Windows将毫无保留地删除该文件(您可以再次运行DIR /X来确认或仅在Window Explorer中检查目录)。 这里的所有都是它的! 通过巧妙地使用非常旧的命令,您可以删除任何文件,而不管文件名有多长。

翻译自: https://www.howtogeek.com/283877/how-to-delete-files-windows-claims-are-too-long/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值