Q:

Is there a way to write a batch file to rename a file using a set variable?

I am trying to create a batch file that makes folders and places files in these folders. I have accomplished that but I want to now rename the file to a set variable (the name of the project)
I have tried the rename function.
@echo off
SET x="Project Name"
md %x%\"Bid Proposals"
md %x%\"Reports"
md %x%\"Drawings"
md %x%\"Specifications"
md %x%\"Addendums"
cd /d  K:\ESTIMATING\2019 ESTIMATING\2019 BID-PROPOSALS\%x%\Bid Proposals
copy "filelocation\Bid Proposal - Template.docx" 
rename "Bid Proposal - Template" "%x% - Bid Proposal"

I would like it to rename the file to the project name using the variable.
It copies and places the file but doesn't rename it.

A:

Too many quotes.
Try
@echo off
SET "pname=Project Name"
for %%a in ("Bid Proposals" "Reports" "Drawings" "Specifications"
 "Addendums") do md "%pname%\%%~a"
cd /d  K:\ESTIMATING\2019 ESTIMATING\2019 BID-PROPOSALS\%pname%\Bid Proposals
copy "filelocation\Bid Proposal - Template.docx" .
rename "Bid Proposal - Template" "%pname% - Bid Proposal"

The syntax SET "var=value" (where value may be empty) is used to ensure that any stray trailing spaces are NOT included in the value assigned.
I've changed x to something more meaningful.
The for assigns each [in this case, quoted] value to %%a in turn. The %%~a removes the quotes from %%a.
I believe the copy will require a destination. I've added . which means the current directory, so the file "filelocation\Bid Proposal - Template.docx" should be copied to the current directory as "Bid Proposal - Template.docx"
The rename will match the filenames, so the from name should probably be `"Bid Proposal - Template.docx" and the to name "%pname% - Bid Proposal.docx"
And I believe the plural of Addendum is probably Addenda.

