How do I delete a file, which has quotes in the name, by CMD?

Asked

Viewed 1,382 times

12

I am deleting a folder from my hard drive and could delete everything except that file.

Because it has quotes, I can’t use short names, and I can’t erase it the way it is.

I tried to fsutil file setshortname, but I can’t keep the quotes in mai_68

I tried double quotes, \, and other special characters, such as %, but the quotes are not recognized by the shell, as you can see:

  • Even with Espace for " that is to use "", could not remove the file. I have tried several ways but all without success! Linux Live CD, delete file, restart ;)

  • @Zuul Publish your suggestion as a response. I tried everything on Windows, including using disk editors (Winhex, Hxd, Diskexplorer), to try to rename the file by force, but on Windows 7 gives access denied... the disk access drivers protect it against writing, where the only way would be to unmount the drive and then edit (the driver leaves). It turns out that the path is very long and boring, or impossible in the case of system drive... it seems easier to download a small Linux Live distro, put on a CD or USB and then do as you said.

  • @Miguelangelo Meti now the answer suggesting a Livecd. I have been trying other methods than the ones you indicated and/or had already tried, but without success! Livecd, 5min and the question is settled :)

3 answers

7

Reserved characters

Under Windows, there are some characters that are reserved (English) as they serve a purpose when used by the operating system:

  • < (less than)
  • > (greater than)
  • : (two-point)
  • " (quotation marks)
  • / (bar)
  • \ (backslash)
  • | (vertical bar)
  • ? (question mark)
  • * (asterisk)

These characters are not allowed in filenames or directories since they are reserved, but this does not mean that they will not be present in them, since many operating systems other than Windows allow their use.

Faced with files or directories that use these characters, it becomes difficult to solve the problem from a system that does not allow its use, so one solution is to use another operating system to rename or remove them.

Solution

Fortunately, using another operating system nowadays does not require more than half a dozen minutes, as is the case with Linux Livecd:

  1. Offload a ISO of Linux;
  2. Download and execute this or other software to create a bootable PEN;
  3. From the list of options, choose the correct distribution, if from the link I left above, will be the option "Linux Mint";
  4. Choose the ISO file of the distribution you downloaded;
  5. Create the startup PEN.

Once created, just use the same to boot the computer, choose the option of "Try".

2

On the command line, and with the current directory where the files are, type:

dir /x

inserir a descrição da imagem aqui

The names enclosed by the orange border are the 8.3 format names.

With the short name of the file, you can delete it.

Source: https://superuser.com/a/381516/90552

  • Nope, unsuccessfully with me! The problem is that " is illegal for filenames or directories... windows does not even let you create files that contain " in the name.

  • @Zuul I could not create a file with double quotes to test... you would know how to do this so I test here?

  • I created using Linux, on Windows I could not. I have both systems in parallel, but you can use a Livecd to quickly create the file and go back to windows.

1

Windows does not recognize files that have special characters, so he understands that this is an invalid file. One way to remove these files is by running the chkdsk with the parameter /f.

chkdsk o: /f

Where O: is the partition where invalid files are found to be fixed. After the operation is completed, a folder is called O:\found.000 will be created containing the file that can now be deleted.

The value 000 can change depending on the amount of invalid files found.

To delete, enter folder found.000 (use cd LETRA to access the partition):

>cd found.000

Then delete all files with the extension .chk:

> del *.chk
  • http://unix.stackexchange.com/questions/102043/how-to-delete-a-ntfs-filesystem-file-whose-name-contains#comment206207_102081

Browser other questions tagged

You are not signed in. Login or sign up in order to post.