How to delete a file ending in a dot in Windows 7?
After installing Cygwin on Windows 7 and realizing I'm better of with using Linux on a different partition, I wanted to uninstall it. However, Cygwin has no uninstaller so I was left with the option of deleting the whole folder it was installed in – which I did.
The problem is that a single file remained, in the whole directory tree, named README.
at C:\cygwin\usr\share\texmf-dist\doc\latex\hausarbeit-jura\README.
I know Windows isn't supposed to allow files with names ending in .
, but this one obviously got through, and I cannot delete it. When trying to do that, I get
Item Not Found
This is no longer located in
C:\cygwin\usr\share\texmf-dist\doc\latex\hausarbeit-jura
. Verify the item's location and try again.
When viewing the properties of the file (Right-click, Properties), Windows tells me that it has 0 bytes. However, when viewing it in the explorer window, and clicking on it, the windows status bar thing tells me it has 517 bytes.
Any ideas on how to get rid of it?
Having tried all of these suggestions and more, I still couldn't delete the offending files.
What finally did it was to use the following syntax (in an elevated command prompt):
del "\\?\<full path to file>"
eg, to use the original example:
del "\\?\C:\cygwin\usr\share\texmf-dist\doc\latex\hausarbeit-jura."
What a really simple solution that I've found. It's the simplest and fastest and easiest way to achieve this. I am now laughing at how simple it is.
- Install WinRAR
- Follow the Step by Step procedure from the pictures:
-
-
-
-
I don't know if you can do it with 7zip, but WinRAR has it and you don't have to buy it, just install the trial and then uninstall it (or probably portables out there but I don't think they are legit i.e. they are possibly cracked.)
Open an elevated command prompt and type in the following commands, pressing Enter after each one:
cd C:\cygwin\usr\share\texmf-dist\doc\latex\hausarbeit-jura\
del *.*
Y
cd c:\
rmdir /s /q C:\cygwin\usr\share\texmf-dist\doc\latex\hausarbeit-jura\
rmdir /s /q C:\cygwin\usr\share\texmf-dist\doc\latex\
rmdir /s /q C:\cygwin\usr\share\texmf-dist\doc\
rmdir /s /q C:\cygwin\usr\share\texmf-dist\
rmdir /s /q C:\cygwin\usr\share\
rmdir /s /q C:\cygwin\usr\
rmdir /s /q C:\cygwin\
The easiest way to do this is to open a Windows Command Prompt window and use the rd
command with the /S /Q
options. You might have to open the Command Prompt as an administrator for this to work.
- Click the
Start Button (Orb)
and locate the link to open the Command Prompt. If you don't see it, you might have to search for it by typingcommand
orcmd.exe
in the search box at the bottom. - Right click on the
command
orcmd.exe
link and selectRun as administrator
, then clickYes
if prompted to allow it. - In the Command Prompt window, type the command (don't press the Enter key yet):
rd /S /Q "C:\Cygwin"
- This command will delete all the files and folders inside the specified folder without prompting, so be sure to double and triple check check that you have specified the correct folder.
- If you want to be prompted to delete the files and sub-folders, type the command without the
/Q
like this:rd /S "C:\Cygwin"
- When you are sure you have typed the command correctly, press the Enter key.
The Cygwin
folder, and all the files and sub-folders within it will be deleted.
Here is the syntax for the rd
command:
C:\>rd /? Removes (deletes) a directory. RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path /S Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree. /Q Quiet mode, do not ask if ok to remove a directory tree with /S
If there are
System
, Hidden,
or Read-only
files or folders that cause the rd
command to fail, use the attrib
command with the /S /D
options like this:
attrib -S -H -R "C:\Cygwin\*.*" /S
to remove those attributes from the files and sub-folders, then re-try the rd
command.
Here's a short VBScript file to do what you need.
Set obj = CreateObject("Scripting.FileSystemObject")
obj.DeleteFile("C:\cygwin\usr\share\texmf-dist\doc\latex\hausarbeit-jura\README.")
This should bypass the issue you're having with the del command and windows explorer. Just save that text as whatever.vbs and double click it.
If the file is flagged as read-only then you'll need to add a bit to that code, let me know.