91

I currently have a file on the root of my external hard drive simply named ._., which I am guessing was added to my hard drive after using it on my MacBook a while ago. I'm trying to delete this file on my Windows 10 machine; however Windows keeps claiming the file cannot be found.

Error message from Windows Explorer

I also tried deleting the file through an elevated command prompt; however the same message is returned.

Error message from elevated command prompt

Is there any way I can delete this file from my hard drive through Windows?

  • 7
    @rr- the misery you can do with unix file names tends to be much greater. :3 – Martijn Nov 9 '15 at 12:51
  • 5
    Your command prompt shows something odd. You did find "._." but left out the quotes for del ._.. Did you try del "._."? – jpmc26 Nov 10 '15 at 3:13
  • 1
    interesting phenomenon. especially how hard it is to delete. Are you sure that the file was legitly created? (the naming of it sounds quite strange even for a mac) – Thomas Nov 10 '15 at 12:15
  • 30
    My favorite part is the file's expression of your attempts to delete it. – Workman Nov 11 '15 at 18:27
  • 8
    "._." You can't delete this because koalas are a protected species. – user153035 Nov 13 '15 at 8:33
144

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 "._."

==>
  • 4
    Worked like a champ, thanks! – Mike Koch Nov 8 '15 at 16:20
  • It is possible to use that prefix with a URL, al a the start command? – Steven Penny Nov 8 '15 at 23:47
  • 1
    ...Can this be used to bypass length limits? (E.g., delete a node_modules directory.) – jpmc26 Nov 10 '15 at 20:55
  • 1
    @jpmc26 As per MSDN (see link provided in my answer), yes. However, I met scenarios where \\?\ prefix used in del or rmdir commands did not help. Turned to 7-zip file manager. – JosefZ Nov 10 '15 at 21:23
  • 2
    @jpmc26: It can bypass some length limits. Basically, an expanded path has a length limit of 32K. But most paths like C:\Windows or .. aren't expanded, and those have a length limit of only 260. That 260 limit is enforced in many places; unfortunately quite a few of those places incorrectly apply that limit also to `\\?` paths. – MSalters Nov 11 '15 at 13:36
24

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

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

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.)

  • 1
    @The_IT_Guy_You_Don't_Like I'm curious, where did OP mention that? – muru Nov 10 '15 at 15:53
  • @Arie Klep, I take my words back. I must have read it in another similar question – pun Nov 10 '15 at 15:56
-8

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

  • 26
    The problem appears to be that Windows cannot access the file at all, because of its non-conforming filename, so I would be very surprised if this answer works. – Scott Nov 8 '15 at 6:52

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.