Page 1 of 1

rename failure

Posted: 03 Feb 2021 14:42
by colmac
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.

Re: rename failure

Posted: 03 Feb 2021 15:55
by Squashman
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.

Re: rename failure

Posted: 04 Feb 2021 04:11
by colmac
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.

Re: rename failure

Posted: 04 Feb 2021 06:41
by dbenham
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