30

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?

Brad Patton
  • 10,668
Vineet
  • 459

4 Answers4

21

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.

Sekhemty
  • 9,916
7

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.

6

You could also try...

From a Windows Command Prompt:

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

or

ren "F:*.csv" "filename.csv"
Kevin Fegan
  • 4,997
4

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

Rich Homolka
  • 32,350