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?

MrMike
  • 1,421
  • 11
  • 19

5 Answers5

143

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

==>
JosefZ
  • 13,855
23

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
Guest
  • 231
22

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.

NZD
  • 2,818
-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.)

-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

user53336
  • 26
  • 2