This is a sample script
robocopy "c:\users\test" "d:\test" "sample.txt" /xf desktop.ini /np /tee /ndl /xx
echo.
if exist "d:\test\sample.txt ren “Sample June 2021” Exit 2 ********
echo.
in the command line if exist "d:\test\sample.txt ren "Sample June 2021" Exit2
I want to copy and rename at the same time and it's not working
Can the copy and rename be on one command line, if so, how do I go about doing that?
Thanks in advance.
Copy and rename on one command line
Moderator: DosItHelp
Re: Copy and rename on one command line
Thanks Rasil for your reply.
How would I combine the 2 commands together on one line.
if exist "d:\test\sample.txt ren “Sample June 2021”
I can't figure out how to make it work using your example.
Can you help?
How would I combine the 2 commands together on one line.
if exist "d:\test\sample.txt ren “Sample June 2021”
I can't figure out how to make it work using your example.
Can you help?
Re: Copy and rename on one command line
How would REN know what file you want to rename?
Also, take care that you don't miss quotes (should usually be an even number in a line) and that you use the right quotation marks ("" rather than “”).
Steffen
Code: Select all
if exist "d:\test\sample.txt" ren "d:\test\sample.txt" "Sample June 2021.txt"
Steffen
Re: Copy and rename on one command line
Thanks to aGerman, Rasil, It worked. You're gurus.