Fog Creek Software
Discussion Board




Problem with Rename on Windows NT Server


Hi Guys,

I've got a little problem with the DOS
RENAME command under Windows NT4 (SP6)

Rename does not seems to work with spaces in the path

IE :

rename C:\Program Files\Navision Financials\Database.fdb C:\Program Files\Navision Financials\Inventaire.fdb

I got a syntax error after typing this command

I guess I must be missing something ...

I have tried the quotes on the source and destination but with no success :-(


Tarek Demiati
Thursday, July 17, 2003

Are you running in the 32-bit command process (CMD.EXE) or the 16-bit DOS emulation (COMMAND.COM)?

The former should support quoted names. The latter doesn't, because it only sees 8.3 names.

Brad Wilson (dotnetguy.techieswithcats.com)
Thursday, July 17, 2003

<rant>
It's not DOS! It's the NT Command Prompt  - as long as you're using CMD.EXE and not command.com (ignore the fact the Command prompt icon in NT4 has an MSDOS icon -- that's marketing for you)
</rant>

Anyway... :-) Put quotes around the filenames. It makes sense really because how is the rename command supposed to differentiate the two files without them if the filenames have spaces in them?

rename "C:\Program Files\Navision Financials\Database.fdb" "C:\Program Files\Navision Financials\Inventaire.fdb"

Duncan Smart
Thursday, July 17, 2003

Note that "rename" does not allow you to specify a new drive or path (and therefore does not allow you to specify any drive or path in the destination filespec even if it's the same as the source). This command will fail (with a syntax error):

RENAME "C:\Program Files\Navision Financials\Database.fdb" "C:\Program Files\Navision Financials\Inventaire.fdb"

But, this will succeed:

RENAME "C:\Program Files\Navision Financials\Database.fdb" "Inventaire.fdb"

(The quotes are only required if the filespec contains spaces.) If you want to specify a different drive or path, use the MOVE command.

Philip Dickerson
Thursday, July 17, 2003

I guess you are missing something. Like the friendly manual for instance.


Thursday, July 17, 2003

To get (brief) usage help on most commands at the command prompt, enter the command followed by /?. For example, help for the RENAME command shows the following:


RENAME /?
Renames a file or files.

RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.

Note that you cannot specify a new drive or path for your destination file.

Philip Dickerson
Thursday, July 17, 2003

Sorry ignore me... I just read where you said "I have tried the quotes on the source and destination but with no success :-("

Brad's could be right, you are using command.com rather than cmd.exe... but as far as I can remember even the 16-bit command.com has support for long filenames... or maybe that was only the Windows 9x family...

-- are you sure you're using regular double quotes? I can's see how they might have been SmartQuote-ed though...

Duncan Smart
Thursday, July 17, 2003

Oh yeah - Philip's answer will be right :-)... I still meant what I said about "DOS prompt" though ;-)

Duncan Smart
Thursday, July 17, 2003

"but as far as I can remember even the 16-bit command.com has support for long filenames... or maybe that was only the Windows 9x family..."

Right, that's only on 9x, where command.com is the one and only interpreter. In that case, it's leveraging DOS extensions to get at long filenames.

Brad Wilson (dotnetguy.techieswithcats.com)
Thursday, July 17, 2003

you can also use 'move' instead of 'rename'.

mb
Friday, July 18, 2003

*  Recent Topics

*  Fog Creek Home