rename failure

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
colmac
Posts: 10
Joined: 29 Nov 2013 11:36

rename failure

#1 Post by colmac » 03 Feb 2021 14:42

Hi can anyone tell me why this command does not work

rename "\\Bon2\D\LR Safe-Bon2\*.*" "\\Bon2\D\LR Safe-Bon2\FH - %fstamp%.*"

It gets rejected as the Syntax of the command is incorrect.

The paths shown are correct, and the variable fstamp shows correctly when Echo is used. But in any even it says the Syntax is wrong, not the path.

I've stared at this for ages, but cant see what I'm doing wrong.

Hope someone can help.

Squashman
Expert
Posts: 4237
Joined: 23 Dec 2011 13:59

Re: rename failure

#2 Post by Squashman » 03 Feb 2021 15:55

Straight from the help file. Read the last line.

Code: Select all

H:\>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.
The syntax usage clearly shows that [PATH] is an option for the source file name but not the target file name.

colmac
Posts: 10
Joined: 29 Nov 2013 11:36

Re: rename failure

#3 Post by colmac » 04 Feb 2021 04:11

It is so simple when someone that knows what they are talking about explains it!

I looked at that for ages, I googled lots of things. And then someone helps.

Thank you very much.

dbenham
Expert
Posts: 2440
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: rename failure

#4 Post by dbenham » 04 Feb 2021 06:41

Note - You can use MOVE to rename a single file or folder. But you cannot use RENAME or REN to move a file or folder.

REN or RENAME capability
  • Rename one or more files or folders without moving them
MOVE capability
  • Move one or more files or folders to a new location, without changing the file or folder name
  • Rename exactly one file or folder, without moving it (the command still labels the action as a move)
  • Move exactly one file or folder to a new location and rename the file or folder

Dave Benham

Post Reply