Monday, September 16, 2019

command line - Windows Unable to Delete ._. File


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?


Answer



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

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...