How to delete a file that contains spaces in the file name?

You can do it like this:

del /F "\\?\C:\My_Dir\Registering*wrong*app*"

This will match any amount of characters between and after the words, and also works on wrong files.

If you don't have other files that start with Registering, you might as well try:

del /F "\\?\C:\My_Dir\Registering*"

If the file is undeletable, use Process Explorer and search for the handle and kill the owning process.

Find --> Find Handle/DLL (CTRL+F) --> Type in Registering --> Kill the matching processes.


Open a command prompt, and change to the My_Dir directory

cd \My_Dir

Get the short (8.3) file name for the file.

dir /a /x /p

You should see something like

02/13/2011  07:25 PM             1,010 REGIST~1     Registering Wrong App

The REGIST~1 is the short file name. Try the del command with that name.

del REGIST~1

Try putting the filename in quotes, but replacing the spaces with question marks, like this:

del "registering?wrong?app"

That should delete the file if the spaces aren't really spaces, but nulls or some other invisible character.

Tags:

Windows 7