I just discovered that my batch file does not work properly for estName input that includes an ampersand.
e.g. 11th & Jefferson Apartments
The result of this input results in the file being renamed to "Concrete Price Proposal - 11th" with no extension.
I am inexperienced with batch files and it took me a little while manipulating quotation marks to get the batch file working properly when spaces were included in estName so I thought I would seek assistance on this one.
Thanks.
NEW ESTIMATE.bat (code outside the scope of the issue has been removed)
@echo off
:estInput
set /p estNum= ENTER NUMBER: E14-
set /p estName= ENTER NAME:
:createFolder
robocopy "S:\Estimating\Master Estimate Files" "S:\Estimating\Estimate Archive\2014\E14-%estNum% %estName%" /E /xc /xn /xo
:renameProposal
forfiles /p "S:\Estimating\Estimate Archive\2014\E14-%estNum% %estName%" /m "Concrete Price Proposal Master - Fax.doc" /c "cmd /c rename @path """Concrete Price Proposal - %estName%.""@ext""
:exit
exit
Win7 - cmd /c rename - Problem with ampersand in file name.
Moderator: DosItHelp
Re: Win7 - cmd /c rename - Problem with ampersand in file na
Try this cmd tail:
Code: Select all
/c "cmd /c rename @path 0x22Concrete Price Proposal - %estName%.@ext0x22"
Re: Win7 - cmd /c rename - Problem with ampersand in file na
That worked! Why is 0x22 processed differently than quotation marks? If the answer is too complex don't worry about answering 

Re: Win7 - cmd /c rename - Problem with ampersand in file na
Each character has a code number, and in this case a double quote is Hex 22 and forfiles represents that as 0x22
The reason why a lot of languages use a code to represent some characters is because some characters already have a special purpose,
and here forfiles (sometimes) has problems with double quotes, as it uses them to surround the cmd /c term.
The reason why a lot of languages use a code to represent some characters is because some characters already have a special purpose,
and here forfiles (sometimes) has problems with double quotes, as it uses them to surround the cmd /c term.