Windows не удается удалить ._. файл

6912
Mike Koch

В настоящее время у меня есть файл в корневом каталоге моего внешнего жесткого диска с простым именем ._., который, я полагаю, был добавлен на мой жесткий диск после использования его на моем MacBook некоторое время назад. Я пытаюсь удалить этот файл на моем компьютере с Windows 10; однако Windows продолжает утверждать, что файл не может быть найден.

Error message from Windows Explorer

Я также попытался удалить файл через командную строку с повышенными правами; однако возвращается то же сообщение.

Error message from elevated command prompt

Можно ли как-нибудь удалить этот файл с моего жесткого диска через Windows?

91
@ rr- страдания, которые вы можете делать с именами файлов Unix, имеют тенденцию быть намного больше. : 3 Martijn 8 лет назад 7
Ваша командная строка показывает что-то странное. Вы действительно "нашли" ._. "`, Но опускали кавычки для `del ._.`. Вы пробовали `del" ._. "`? jpmc26 8 лет назад 5
@ jpmc26 Да, я попробовал это. Пришел с тем же результатом. Mike Koch 8 лет назад 0
интересное явление. особенно как трудно это удалить. Вы уверены, что файл был законно создан? (это звучит довольно странно даже для Mac) Thomas 8 лет назад 1
Моя любимая часть - это выражение файла ваших попыток удалить его. Workman 8 лет назад 29
`" ._. "` Вы не можете удалить это, потому что коалы - защищенный вид. 8 лет назад 7

5 ответов на вопрос

144
JosefZ

Run the following command (could require elevated privileges / open command prompt as administrator):

del "\\?\F:\._." 

About the \\?\ prefix:

For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system.

...

Because it turns off automatic expansion of the path string, the "\\?\" prefix also allows the use of ".." and "." in the path names, which can be useful if you are attempting to perform operations on a file with these otherwise reserved relative path specifiers as part of the fully qualified path.

Note that you cannot use the "\\?\" prefix with a relative path.

Example:

==> set prog>"\\?\D:\bat\Unusual Names\._." ==> dir "D:\bat\Unusual Names\*"|find "._." 08.11.2015 13:25 132 ._. ==> type "D:\bat\Unusual Names\._." The system cannot find the file specified. ==> type "\\?\D:\bat\Unusual Names\._." ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files ==> del "D:\bat\Unusual Names\._." Could Not Find D:\bat\Unusual Names\._. ==> del "\\?\D:\bat\Unusual Names\._." ==> dir "D:\bat\Unusual Names\*"|find "._." ==> 
Работал как чемпион, спасибо! Mike Koch 8 лет назад 4
Можно использовать этот префикс с URL-адресом, а также командой `start`? Steven Penny 8 лет назад 0
Вы не используете это с URL. Вы используете двойные кавычки, если хотите запустить URL из команды запуска. Nelson 8 лет назад 0
... Может ли это использоваться, чтобы обойти ограничения длины? (Например, удалите каталог `node_modules`.) jpmc26 8 лет назад 1
@ jpmc26 Согласно MSDN (см. ссылку в моем ответе), да. Однако я встречал сценарии, в которых префикс `\\? \`, Используемый в командах `del` или` rmdir`, не помог. Обратился к `7-zip` файловому менеджеру. JosefZ 8 лет назад 1
@ jpmc26: может обойти некоторые ограничения по длине. По сути, расширенный путь имеет ограничение длины 32 КБ. Но большинство путей, таких как `C: \ Windows` или` ..`, не раскрываются, и их длина ограничена только 260. Этот предел в 260 применяется во многих местах; к сожалению, многие из этих мест неправильно применяют этот предел и к путям `\\? \`. MSalters 8 лет назад 2
24
Guest

Even though the question has already been answered, I'd still like to offer a possible alternative solution: using the legacy "short names" (which you can display with the "/x" option to the dir command) can also allow you to get a grip on files with "funky" names that you can't handle otherwise:

C:\temp\test>dir Volume in drive C has no label. Volume Serial Number is 887A-5E48 Directory of C:\temp\test 11.11.2015 16:31 <DIR> . 11.11.2015 16:31 <DIR> .. 11.11.2015 16:31 7 ._. 1 File(s) 7 bytes 2 Dir(s) 44.966.129.664 bytes free C:\temp\test>dir /x Volume in drive C has no label. Volume Serial Number is 887A-5E48 Directory of C:\temp\test 11.11.2015 16:31 <DIR> . 11.11.2015 16:31 <DIR> .. 11.11.2015 16:31 7 _3E35~1 ._. 1 File(s) 7 bytes 2 Dir(s) 44.966.129.664 bytes free C:\temp\test>del _3e35~1 C:\temp\test>dir Volume in drive C has no label. Volume Serial Number is 887A-5E48 Directory of C:\temp\test 11.11.2015 16:31 <DIR> . 11.11.2015 16:31 <DIR> .. 0 File(s) 0 bytes 2 Dir(s) 44.966.129.664 bytes free 
20
NZD

Install 7-zip, open it and use its file menu to rename the file to a normal name (for instance to aaa) and then you can delete it. Found at this post.

I tested this on Windows XP running in a VM. I used Linux to create a file called ._. on a shared directory.

-4
Arie Klep

Just op your windows explorer, navigate to the file. Rename the file like : filename.txt Now you can delete it. If you are not able to do this then you need to be sure you have admin rights.

(btw the reason why you can't delete it is because the filename has actually no-name and the extention is not valid. The filename is "." and the extension is "__." which is not allowed.)

@ The_IT_Guy_You_Dont_Like Мне интересно, где OP упомянул об этом? muru 8 лет назад 1
@ Арье Клеп, я забираю свои слова обратно. Я должен был прочитать это в другом подобном вопросе pun 8 лет назад 0
-8
user53336

You can delete the file by 1) Take ownership 2) grant administrators (you) full permission 3) Do what you want with the file

Elevated CMD prompt

takeown /f Full Path to Undeletable File (last item must be the undeletable file)

icacls Full Path to Undeletable file /grant administrators:f

Delete file

Проблема заключается в том, что Windows вообще не может получить доступ к файлу из-за своего несоответствующего имени файла, поэтому я был бы очень удивлен, если этот ответ работает. Scott 8 лет назад 26