33

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?

migrated from stackoverflow.com Oct 28 '12 at 21:19

This question came from our site for professional and enthusiast programmers.

  • This is a shot in the dark, as I'm not sure what steps you've taken, but have you tried deleting it from the cli? – Sturm Oct 26 '12 at 18:04
  • Yes, I do get the exact same error. – user241543903 Oct 26 '12 at 18:15
  • You can write a short program to unlink specifically that file. That WILL work. – OmnipotentEntity Oct 26 '12 at 18:39
  • 1
    Why not simply use wildcards: del README*? – Dmitry Grigoryev Jun 15 '17 at 13:02
51

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."
  • I did this when the vbs script solution in the accepted answer did not work. The file is gone now :] – FRob Jun 25 '15 at 10:01
  • This works! Really awesome! – Paul Vargas May 29 '17 at 20:56
  • This should be the accepted answer. – Gaurav Jun 9 '17 at 7:26
  • 1
    This works with del but doesn't work with some other cmd builtins like move and rename. – ivan_pozdeev Aug 30 '18 at 13:24
  • 1
    Its 2019 and I can confirm this works - and seems to be the easiest solution to do. Unclear if it matters, but I ran it from a CMD started in administrator mode. Thanks @micha – Paul T. Feb 16 at 16:08
15

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.

  1. Install WinRAR
  2. Follow the Step by Step procedure from the pictures:
  3.  
    enter image description here
  4.  
    enter image description here
  5.  
    enter image description here
  6.  
    enter image description here

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

  • 2
    Great trick. The only thing that worked for me – Cynapse Mar 20 '16 at 18:45
  • 2
    7zip works fine. Thx :-). – Michał Powaga Nov 6 '16 at 10:14
  • 1
    I really like it, because in my experience broken files are often result of using WinRar – user502144 Nov 11 '16 at 18:39
  • Very nice one. Winrar created my files, it should be able to delete them – user1156544 May 29 '17 at 16:17
  • 2
    7-zip worked for me – HackSlash Sep 19 '17 at 15:38
6

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\
  • 2
    I guess del *.* would have sufficed as an aswer... – Florian Ledermann Sep 22 '17 at 14:26
4

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.

  1. 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 typing command or cmd.exe in the search box at the bottom.
  2. Right click on the command or cmd.exe link and select Run as administrator, then click Yes if prompted to allow it.
  3. In the Command Prompt window, type the command (don't press the Enter key yet):
    rd /S /Q "C:\Cygwin"
  4. 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.
  5. 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"
  6. 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.

2

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.

  • 6
    I managed to delete the file in cli using DEL *.* (DEL README. wouldn't work). However the folder still couldn't be deleted. Your script, adjusted for folders, did the trick. Cheers! – user241543903 Oct 26 '12 at 19:10
1

The way I did it was pretty easy. I have a dual-boot system with Linux, so I just booted into Linux, navigated to the file and deleted it. I'm sure you could do the same with a live CD.

1

Use bash rm command from Ubuntu on Windows 10

0

I had an image that has no extension by the name cropped_image_new1597487825.

Just open the elevated Command Prompt,

Type dir /x to obtain the 8.3 formatted filenames.

Delete the file using the 8.3 filenames, e.g. 'del CROPPE~2'

Here is a working example:

C:\Users\Acer\Desktop\proj_ci\uploads\profile_pic>del cropped_image_new1597487825.
Could Not Find C:\Users\Acer\Desktop\proj_ci\uploads\profile_pic\cropped_image_new1597487825.

C:\Users\Acer\Desktop\proj_ci\uploads\profile_pic>dir /x
 Volume in drive C is Windows 7
 Volume Serial Number is 6616-BD66

 Directory of C:\Users\Acer\Desktop\proj_ci\uploads\profile_pic

05-11-2018  12:09    <DIR>                       .
05-11-2018  12:09    <DIR>                       ..
05-11-2018  12:06                 0 CROPPE~2     cropped_image_new1597487825.
               1 File(s)              0 bytes
               2 Dir(s)   6,169,853,952 bytes free


C:\Users\Acer\Desktop\proj_ci\uploads\profile_pic>del CROPPE~2

C:\Users\Acer\Desktop\proj_ci\uploads\profile_pic>dir /x
 Volume in drive C is Windows 7
 Volume Serial Number is 6616-BD66

 Directory of C:\Users\Acer\Desktop\proj_ci\uploads\profile_pic

31-01-2019  14:58    <DIR>                       .
31-01-2019  14:58    <DIR>                       ..
               0 File(s)              0 bytes
               2 Dir(s)   6,169,702,400 bytes free
-2

There are a number of ways to tackle this issue, but the most simple way is with the DEL command, as mentioned above.

It's important to note, however, that DEL by itself will not work as the files in this case tend to get flagged with the System attribute thus you must issue a special parameter to have them show up.

In order to see them in CMD prompt using DIR, navigate to the folder in question and issue the following command:

Dir /A

That will list all files in that directory regardless of attribute. Then to delete it just issue the following command, issuing the same /A parameter:

DEL *.* /A

Of course that deletes all files in that dir, so if you want other files to remain you should move them out or back them up first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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