Windows Unable to Delete ._. File

91

29

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?

Mike Koch

Posted 2015-11-08T04:14:48.627

Reputation: 1 421

7@rr- the misery you can do with unix file names tends to be much greater. :3 – Martijn – 2015-11-09T12:51:16.823

5Your command prompt shows something odd. You did find "._." but left out the quotes for del ._.. Did you try del "._."? – jpmc26 – 2015-11-10T03:13:28.857

@jpmc26 yep I tried that. Came up with the same result. – Mike Koch – 2015-11-10T03:18:33.917

1interesting 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 – 2015-11-10T12:15:19.637

31My favorite part is the file's expression of your attempts to delete it. – Workman – 2015-11-11T18:27:09.280

9"._." You can't delete this because koalas are a protected species. – None – 2015-11-13T08:33:26.217

Answers

146

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

Posted 2015-11-08T04:14:48.627

Reputation: 9 121

It is possible to use that prefix with a URL, al a the start command? – Steven Penny – 2015-11-08T23:47:28.313

You don't use this with a URL. You use double quotes if you want to run a URL from the start command. – Nelson – 2015-11-09T00:48:17.563

1...Can this be used to bypass length limits? (E.g., delete a node_modules directory.) – jpmc26 – 2015-11-10T20:55:32.030

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 – 2015-11-10T21:23:37.387

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 – 2015-11-11T13:36:25.237

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

Guest

Posted 2015-11-08T04:14:48.627

Reputation: 241

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.

NZD

Posted 2015-11-08T04:14:48.627

Reputation: 2 142

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

Arie Klep

Posted 2015-11-08T04:14:48.627

Reputation: 1

1@The_IT_Guy_You_Don't_Like I'm curious, where did OP mention that? – muru – 2015-11-10T15:53:23.440

@Arie Klep, I take my words back. I must have read it in another similar question – pun – 2015-11-10T15:56:11.463

-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

Posted 2015-11-08T04:14:48.627

Reputation: 26

27The 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 – 2015-11-08T06:52:48.013