randy ford
randy ford

Reputation: 11

convert to powershell script

    @echo off


::
:: Grabbing the users input of job number to create
:: 
SET /P JobNum="Enter Job Number: "


::
:: Creating the job number folder structure
::
MKDIR "\\server\jobs\%JobNum%"
MKDIR "\\server\jobs\%JobNum%\DataPrep"
MKDIR "\\server\jobs\%JobNum%\DataPrep\Data"
MKDIR "\\server\jobs\%JobNum%\DataPrep\Data\Input"
MKDIR "\\server\jobs\%JobNum%\DataPrep\Data\Working"
MKDIR "\\server\jobs\%JobNum%\DataPrep\Programs"
MKDIR "\\server\jobs\%JobNum%\DataPrep\Docs"
MKDIR "\\server\jobs\%JobNum%\Prepress"
MKDIR "\\server\jobs\%JobNum%\Prepress\Working"
MKDIR "\\server\jobs\%JobNum%\Prepress\PNetImages"
MKDIR "\\server\jobs\%JobNum%\CSR"
MKDIR "\\server\jobs\%JobNum%\Production"
MKDIR "\\server\jobs\%JobNum%\Production\MailDocs"
MKDIR "\\server\jobs\%JobNum%\Production\Output"

Need this converted to PS script. Not sure about the PS commands and how they translate from a batch file.

Upvotes: 1

Views: 238

Answers (1)

Eddy Steenbergen
Eddy Steenbergen

Reputation: 36

Try something like this:

$JobNum = Read-Host -Prompt "Enter Job Number: "
("",
"\DataPrep",
"\DataPrep\Data",
"\DataPrep\Data\Input",
"\DataPrep\Data\Working",
"\DataPrep\Programs",
"\DataPrep\Docs",
"\Prepress",
"\Prepress\Working",
"\Prepress\PNetImages",
"\CSR",
"\Production",
"\Production\MailDocs",
"\Production\Output") |
foreach-object { new-item -type directory -path "\server\jobs\$JobNum$_" }

Upvotes: 1

Related Questions