This is real close to what I am using to create various widgets. I edited the code just enough that it does not matter if it is reused. I am going to be scripting this into PowerShell later, but for now I'll deal with what I've got. I am having issues with an invisible else "'else' is not recognized as an internal or external command." After the error the code is jumping to :CreatProdDir and skipping everything else.
@ECHO OFF
GOTO SetPathLocations
:SetPathLocations
CLS
SET JobPath="C:\NewCustomer\_Template"
SET SamplesPath="C:\NewCustomer\_Samples"
SET Type1Path="C:\NewCustomer\Product1"
SET Type2Path="C:\NewCustomer\Product2"
SET Type3Path="C:\NewCustomer\Product3"
SET Type4Path="C:\NewCustomer\MULTOS"
PAUSE
GOTO CollectData
:CollectData
SET /p CUSTName="Enter Customer Name (example: Mega_Warehouse or MegaWarehouse): "
SET /p SHRTName="Enter Customer Name (example: MegaWH or MWH): "
SET /p CustNum="Enter Customer Number: "
SET /p PRODType="Enter Product1, Product2, Product3, Product4 or Product5: "
SET /p RequestName="Enter new requested name: "
SET /p PhoneNum="Enter the phone number: "
SET /p VerNum="Enter release version (v1.0.0, v2.0.0, etc...): "
PAUSE
GOTO SetNewPath
:SetNewPath
IF /I PRODType==Product1 ( SET NewPath=%Type1Path%)
IF /I PRODType==Product2 ( SET NewPath=%Type2Path%)
IF /I PRODType==Product3 ( SET NewPath=%Type3Path%)
IF /I PRODType==Product4 ( SET NewPath=%Type4Path%)
IF /I PRODType==Product4 ( SET NewPath=%Type4Path%)
PAUSE
GOTO CheckCustomer
:CheckCustomer
IF EXIST %NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\nul GOTO Retry
PAUSE
GOTO Validate
:Validate
IF /I PRODType==Product1 ( GOTO Product1 )
IF /I PRODType==Product2 ( GOTO Product2 )
IF /I PRODType==Product3 ( GOTO Product3 )
IF /I PRODType==Product4 ( GOTO Product4 )
IF /I PRODType==Product4 ( GOTO Product4 )
PAUSE
GOTO Retry
Type1Path="C:\NewCustomer\Product1"
:Product1
MD "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%"
PAUSE
GOTO CreatProdDir
Product2Path="C:\NewCustomer\Product2"
:Product2
MD "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%"
Echo Creating working %CUSTName%....
echo:
xcopy "%NewPath%\Collection\*.*" "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\*.*" /h/e/c/k/y/r
echo:
xcopy "%NewPath%\Customer_TEMPLATE\*.*" "%NewPath%\%CUSTName%\TEMPLATE_%VerNum%\*.*" /h/e/c/k/y/r
echo: This is to create a local directory structure
MD "C:\%PRODType%\%SHRTName%\Release"
Echo Creating new file requirements for %CUSTName%
echo f | xcopy "%JobPath%\Job.18888888888.xml" "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\Jobs\Job.%PhoneNum%.xml" /h/e/c/k/y/r
echo f | xcopy "%SamplesPath%\Sample.txt" "%NewPath%\%CUSTName%\%SHRTName%_%VerNum%_%PRODType%_ProjectInfo.txt" /h/e/c/k/y/r
echo f | xcopy "%SamplesPath%\Instructions.docx" "%NewPath%\%CUSTName%\%SHRTName%_%VerNum%_%PRODType%_Instructions.docx" /h/e/c/k/y/r
PAUSE
GOTO Exit
Type3Path="C:\NewCustomer\Product3"
:Product3
MD "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%"
Echo Creating working %CUSTName%....
echo:
xcopy "%NewPath%\Collection\*.*" "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\*.*" /h/e/c/k/y/r
echo:
xcopy "%NewPath%\Customer_TEMPLATE\*.*" "%NewPath%\%CUSTName%\DataGen_%VerNum%\*.*" /h/e/c/k/y/r
echo Creating new file requirements for %CUSTName%
echo f | xcopy "%NewPath%\Job.18888888887.xml" "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\Jobs\Job.%PhoneNum%.xml" /h/e/c/k/y/r
echo f | xcopy "%SamplesPath%\Sample.txt" "%NewPath%\%CUSTName%\%SHRTName%_%VerNum%_%PRODType%_ProjectInfo.txt" /h/e/c/k/y/r
echo f | xcopy "%SamplesPath%\Instructions.docx" "%NewPath%\%CUSTName%\%SHRTName%_%VerNum%__%PRODType%_Instructions.docx" /h/e/c/k/y/r
PAUSE
GOTO RunPShell
Type1Path="C:\NewCustomer\Product4"
:Product4
MD "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%"
Echo Creating %CUSTName% directory
echo:
xcopy "%NewPath%\Product4\*.*" "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\*.*" /h/e/c/k/y/r
echo Creating new file requirements for %CUSTName%
echo f | xcopy "%SamplesPath%\Product4_Instructions.docx" "%NewPath%\%CUSTName%\%SHRTName%_%VerNum%_%PRODType%_Instructions.docx" /h/e/c/k/y/r
echo f | xcopy "%SamplesPath%\SampleProduct4Information.txt" "%NewPath%\%CUSTName%\%SHRTName%_%VerNum%_%PRODType%_Info.txt" /h/e/c/k/y/r
PAUSE
GOTO CreatProdDir
Type1Path="C:\NewCustomer\Prod5"
:Product5
MD "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%"
Echo Creating %CUSTName% directory
echo:
xcopy "%NewPath%\Product5\*.*" "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\*.*" /h/e/c/k/y/r
echo Creating new file requirements for %CUSTName%
echo f | xcopy "%SamplesPath%\Product5_Instructions.docx" "%NewPath%\%CUSTName%\%SHRTName%_%VerNum%_%PRODType%_Instructions.docx" /h/e/c/k/y/r
echo f | xcopy "%SamplesPath%\SampleProduct5Information.txt" "%NewPath%\%CUSTName%\%SHRTName%_%VerNum%_%PRODType%_Info.txt" /h/e/c/k/y/r
PAUSE
GOTO CreatProdDir
:CreatProdDir
SET Proddir="%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\ProductInfo"
SET "ProdCount=1"
SET /p ProdCount="Number of Products in Customer? (default: %ProdCount%): "
for /L %%a in (1,1,%ProdCount%) do (
SET /p PRODName="Enter %%a Product Number: "
call MD "%Proddir%\%%PRODName%%"
)
SET "ProdCount="
PAUSE
GOTO Exit
:RunPShell
powershell "$fileContents = Get-Content -Path %NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%\Customer\%RequestName%.xml"
powershell "[xml]$xmlFile = $fileContents.Replace('CustNum="3503053131dfalj042898"','CustomerID="%CustNum%"')
powershell "[xml]$xmlFile = $fileContents.Replace('\\SHRTName\\','\\%SHRTName%\\)
PAUSE
GOTO exit
:Retry
CLS
echo:
echo:
echo "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%"
echo The customer and version already EXIST. You should make sure another Engineer
echo has not already begun working on this customer. IF you must take over you'll
echo need to find that Engineer's copy of the document in order
echo to pick up where the Engineer left off.
echo:
echo:
SET /p StartOver="Start customer creation over^? (yes or no): "
PAUSE
GOTO StartOver
:StartOver
IF /I StartOver==yes ( GOTO SetPathLocations )
PAUSE
GOTO ExitRetry
:Exit
CLS
echo:
echo:
echo Customer Creation completed for %CUSTName%
echo Find new release work in "%NewPath%\%CUSTName%\%PRODType%_%SHRTName%_%CustNum%_%VerNum%"
echo Find local folder and files in "C:\%PRODType%\%SHRTName%\Release"
echo Creatation Complete
echo:
echo:
PAUSE
:ExitRetry
CLS
PAUSE
exit
Aucun commentaire:
Enregistrer un commentaire