Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

Inadvertently, I have created a file named g:\filename.csv on Windows XP through a Python script.

Note that g:\filename.csv is the filename. Actually it is saved on the F: drive.

I can't rename it using command prompt (ren oldfilename newfilename) or using F2 in an Explorer window. It says "can't read from drive" - Windows thinks the file is on the G: drive.

Is there any way to rename it?

share|improve this question

marked as duplicate by Karan, Brad Patton, Ƭᴇcʜιᴇ007, 8088, Renan May 4 '13 at 19:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
does *filename.csv work? –  BlueRaja May 2 '13 at 20:35
8  
Also, though you have your solution already, could you post the code that created the file? I didn't think the Windows File APIs even allowed you to specify an invalid filename.. –  BlueRaja May 2 '13 at 20:39
5  
You should file a bug to Linux/Ubuntu. The filesystem driver should know that this is an invalid filename for the targeted drive and consequently shouldn't allow to create such a file. It should still allow to address such files if they already exist, in order to remove or rename them though. –  Devolus May 3 '13 at 7:47
6  
2  
There's actually nothing invalid about this file name as far as NTFS is concerned, it's merely a limitation of Windows that prevents it from being properly referenced. –  phogg May 3 '13 at 11:55

4 Answers 4

up vote 21 down vote accepted

This couldn't be the fastest solution, but it should work.
If you boot a Live Linux distro you can delete it, since Linux uses a different method to identify partitions and won't be forced to think that your file is a drive. I suggest you Parted Magic, that has many handy tools for disk and system maintenance and, beside your current concern, is always useful to have it at hand.

share|improve this answer
1  
I am dual-booting with Ubuntu. So this can be tried easily. Let me try and give feedback here. Thanks. –  Vineet May 2 '13 at 12:49
7  
Done. From Ubuntu, I deleted. the file. Thanks. –  Vineet May 2 '13 at 12:53
1  
I used to have the top rated answer that said use \\?\ before the name. I was wrong and that method will not work, so I deleted my answer. You need to use this answer's method or one of the other answers. –  Scott Chamberlain May 5 '13 at 19:37

If your OS Windows then you can use the following trick:

1. Issue command `dir /X`
2. Find out your file in 8 dot 3 notation
3. Use 8 dot 3 notation for file operations as ren, del, copy, print and others.

Note, if you managed to create file with name con or some other Windows device reserved names then you are out of luck with the approach.

share|improve this answer

You could also try...

From a Windows Command Prompt:

ren "F:???filename.csv" "filename.csv"

or

ren "F:*.csv" "filename.csv"
share|improve this answer

You could always try Cygwin. The path name filter in it should be more compliant to this type of error, since this doesn't violate POSIX standards. Install bash and fileutils and then try rm /cygdrive/f/g:\\filename.csv

share|improve this answer

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