41

Possible Duplicate:
How to force Windows XP to rename a file with a special character?
how to delete (invalid) files with colon in their name under windows

I want to delete a file named workspaces\google-gson-1.7.1-release.zip Yep, it contains a backslash in the name.

Here it is:

G:\>dir Z_DRIVE
 Volume in drive G is samsung
 Volume Serial Number is 48B9-7E1D

 Directory of G:\Z_DRIVE

04/06/2012  08:09 PM    <DIR>          .
04/06/2012  08:09 PM    <DIR>          ..
05/01/2011  02:21 PM           528,016 workspaces\google-gson-1.7.1-release.zip
           1 File(s)        528,016 bytes
           2 Dir(s)  88,400,478,208 bytes free

The first attempt is to just delete it from the Windows Explorer, but it says it can't find the file.

Then, I tried from the command line:

G:\>del Z_DRIVE\workspaces\google-gson-1.7.1-release.zip
The system cannot find the file specified.

And, after researching a bit in the internets, I also tried the following, with no luck:

G:\>del \\?\G:\Z_DRIVE\workspaces\google-gson-1.7.1-release.zip
The system cannot find the file specified.

Other than booting from some Linux CD, is there a way to get rid of this file?

Update on 6 April 2012: also tried the following combinations, but the error is the same:

G:\>del "\\?\G:\Z_DRIVE\workspaces\google-gson-1.7.1-release.zip"
G:\Z_DRIVE>del workspaces\google-gson-1.7.1-release.zip
G:\Z_DRIVE>del "workspaces\google-gson-1.7.1-release.zip"
G:\Z_DRIVE>del workspaces*google-gson-1.7.1-release.zip

Update on 7 April 2012: Before I go ahead and try from Linux, here's an screenshot that shows some of the attempts based on the answers here. I'm not sure this will be easy to reproduce, and removing the friggin' file from Linux or using Cygwin feels like cheating :)

Some of the removal attempts

15
  • Have you tried renaming it to something else and then deleting it?
    – Alex
    Apr 6, 2012 at 18:42
  • Is there anything else in there that starts with workspaces? Apr 6, 2012 at 18:42
  • 13
    How did you get such a file? It's a good trick to annoy someone :-)
    – nalply
    Apr 6, 2012 at 22:11
  • @Moab it's not a duplicate, this one is trickier!
    – espinchi
    Apr 7, 2012 at 2:49
  • 1
    Delete the folder Z_DRIVE, make a new folder Z_DRIVE?
    – Konerak
    Apr 7, 2012 at 10:05

17 Answers 17

8

How about running CHKDSK?

There was a similar question here: How to force Windows to rename a file with a special character?, one of the answers to which demonstrated that CHKDSK deletes files with invalid characters in their name.

2
  • A chkdsk /F fixed it! It basically deleted the file :)
    – espinchi
    Apr 10, 2012 at 23:43
  • Had a file with a forward slash in it (was supposed to be a dash but a bit got flipped somewhere). Couldn't delete with explorer, cmd, short name, powershell, or cygwin, but chkdsk removed it from the index then automatically restored it with the correct name. Yay!
    – Cameron
    Jun 5, 2017 at 15:27
30

I would try using short 8.3 naming:

del worksp~1.zip

since that does not seem to work for this specific file, the next thing that I would try is to open a Powershell command prompt then do:

Get-ChildItem G:\Z_Drive\* | Where-Object{$_.Name -Like 'workspaces*'} | Remove-Item -WhatIf

Be sure to play around with the pattern so that you are only matching that one file (not sure if there are other files in there or not). Once you see that it would only try to delete the one file, remove the -WhatIf

10
  • 1
  • 1
    dir /X shows shortnames with the directory listing.
    – Rob
    Apr 6, 2012 at 23:15
  • 3
    That's a great suggestion, I was convinced it would work... but it does not! As @Rob has suggested, I've used dir /x to find out the short name but... the short name is the same as the long name. Can't believe it!
    – espinchi
    Apr 7, 2012 at 2:46
  • Care to explain how this works?
    – Ivo Flipse
    Apr 7, 2012 at 8:54
  • 3
    You might be able to set the short name for the file manually: fsutil file setshortname G:\workspaces\google-gson-1.7.1-release.zip google.zip. See: technet.microsoft.com/en-us/library/cc788058%28v=ws.10%29.aspx Apr 7, 2012 at 17:47
9

open a cmd, do dir/x and find the short name of the file, and delete that.

3
  • Believe it or not, the output of dir /x is _ workspaces\google-gson-1.7.1-release.zip_. I was convinced that this answer (which coincides with @EBGreen's) would work, though!
    – espinchi
    Apr 7, 2012 at 2:48
  • Really weird, other than trying to delete the parent dir recursively if you have not tried yet, I am totally stumped. If you can boot a Linux live cd and still see the file, probably you can delete from there. You may have to mount it rw as sometimes mtgs is only mounted ro. Very interesting and I wish I could get to it myself to try. Finally you may have to call Microsoft if all fails.
    – johnshen64
    Apr 7, 2012 at 4:14
  • Yeah, it's really weird. I did try deleting the parent folder, it was actually my original objective.
    – espinchi
    Apr 8, 2012 at 10:14
4

Could you try renaming it?

rename *.zip tmp.zip
2
  • Or see if something like fileassassin would do the trick...
    – Ross Aiken
    Apr 7, 2012 at 8:06
  • Nop, it says "The system cannot find the path specified". Good idea, though
    – espinchi
    Apr 7, 2012 at 20:23
4

did you try with powershell? if not, try :

First move to the folder, then start powershell (typing powershell, enter) then copy it:

ls | ?{$_.name -like "*\*"} | %{$_.delete()}
2
  • That regex is invalid. And PowerShell has less support than cmd for certain NTFS features (e.g. ADS). I wouldn't expect that to work.
    – Joey
    Apr 7, 2012 at 9:21
  • You are right! Fixed :).
    – Lucas
    Apr 24, 2012 at 2:31
3

Can you type the first part of the filename and do a tab autocomplete? This often formats the filename in whatever specific way the system requires (double slashes, triple quotes, etc.)

1
  • Good suggestion. I've used auto-complete everytime it was possible, to avoid typos.
    – espinchi
    Apr 7, 2012 at 20:23
3

Install cygwin tools from http://cygwin.com

Then ...

rm filename

That should do the trick.

An installation guide is here: http://www.mobilefish.com/developer/cygwin/cygwin.html

1
  • It doesn't work either! I tried both with "\\" (as it appears in ls) and with single backslash and quotes.
    – espinchi
    Apr 7, 2012 at 20:46
2

Try surrounding the file name in double quotes (").

2
  • and if that doesn't work alone, use the double quotes at the end and only escape the single slash. Apr 6, 2012 at 18:35
  • Tried that, but no luck. I updated the original question with this suggestion. Good try, anyway :)
    – espinchi
    Apr 6, 2012 at 18:41
2

try:

del workspaces*google-gson-1.7.1-release.zip

* is a special char that means everything so using this command you will delete

workspaces\google-gson-1.7.1-release.zip
workspacesagoogle-gson-1.7.1-release.zip
workspacesaeiougoogle-gson-1.7.1-release.zip
and so on..

EDIT:

if possibile, move all the files and folder out from Z_DRIVE and then remove directly the directory... then create a new Z_DRIVE and move back the previously moved...

2
  • Tried that, but no luck. I updated the original question with this. Good try, anyway :)
    – espinchi
    Apr 6, 2012 at 18:40
  • updated my answer with a workaround, is not exactly what you want to do, but the final result should be the same...
    – Marcx
    Apr 6, 2012 at 18:49
2

These types of oddly name files, I believe can only be created and removed from script, application, etc. So, you could create a windows script with WSH and use it there MS reference has the perfect example.

// JScript.
Shell = new ActiveXObject("WScript.Shell");
FSO = new ActiveXObject("Scripting.FileSystemObject");
DesktopPath = Shell.SpecialFolders("Desktop");
FSO.DeleteFile(DesktopPath + "\\test.lnk")

' VBScript.
Set Shell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
DesktopPath = Shell.SpecialFolders("Desktop")
FSO.DeleteFile DesktopPath & "\test.lnk"
2

to solve the files there is a working way, install linux-ubuntu or use it with live cd, then go and delete the file... this thing happen to me when i make files with "xxx" on fat drive when i try to open rename or delete it on windows never allow, hope this help

1

Believe it or not, the output of dir /x is _ workspaces\google-gson-1.7.1-release.zip_

Sorry, I think you're looking at the wrong column of the output. The "dir /x" command should display the alternative name for any files with more than 8 characters in the name. Can you display the output of this command in your question like you did for the "dir" command please?

C:\Windows>dir /x
Volume in drive C is OS
Volume Serial Number is 9080-5E4E

Directory of C:\Windows

01/01/2012  18:29    <DIR>                       .
01/01/2012  18:29    <DIR>                       ..
14/07/2009  06:32    <DIR>                       addins
14/07/2009  04:20    <DIR>          APPCOM~1     AppCompat
11/08/2011  18:12    <DIR>                       AppPatch

As you can see, the directory "AppCompat" is the only folder with more than 8 characters so has been given a short name. The 4th column displays the short name (if created).

2
  • dir /x doesn't create short names. That's a feature of the file system and it can be turned off. Fundamentally it's just another hardlink. Also this isn't an answer.
    – Joey
    Apr 7, 2012 at 10:42
  • 3
    I didn't mean create and I have adjusted the answer. I'm not able to comment on the original question or other people's answers because I only have 1 rep so I have to create an answer to help the OP. I do believe it is a valid answer if the OP was missing the 4th column of the command's output and this helps to solve the problem.
    – PhilJ
    Apr 7, 2012 at 11:33
0

Try these small but powerful utilities: lockhunter or unlocker.

0

Assuming that you are using the Android SDK, you can try to delete it from the Android Shell using the rm command. Here is an example, under the From the Recovery Screen section.

0

Since Z_DRIVE only contains one thing, just delete the directory and then recreate it.

0

It sound stupid but you can try Java. I remember I have a few times hit some file like you. And they were created by Java, and removed by java.

Another way to workaround is try to move the folder. Move all the other file away and del the folder recursively, there is some tools to remove folder without iterate the files inside.

0

It looks like this drive is associated with Google Workspace or Google Online docs which creates a drive on your desktop. I would suggest finding the App that handles this and deleting the file or folder from the Google Docs interface or uninstalling it, although that might also get rid of other files on the drive folder, so be sure to back up your data first.

Not the answer you're looking for? Browse other questions tagged .