Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible run two commands at once such as

cd "C:/users/..." and Dir | -Rename-Item -NewName {...}

I want to know if this is possible since it will drastic speed up what I am trying to do.

share|improve this question
up vote 2 down vote accepted

From your description, it sounds like you are trying to run two commands sequentially. The way to do this is with a script. PowerShell uses .ps1 files for scripts. Running scripts in PowerShell is a little more complicated then scripts through the command line. You will need to enable running scripts, create the script, and finally run the script with the right command.

First you need to enable running scripts. Open PowerShell and run the command:

Set-ExecutionPolicy RemoteSigned

This will allow you to run scripts from your local computer.

Second, you need to write the script, You can use any tool you like, such as notepad, but if you want to get fancy, I recommend, PowerGUI script editor or Notepad++ so you can get proper syntax highlighting and such. In the case of your script, just copy the code onto two lines:

cd "C:/users/..." and 
Dir | -Rename-Item -NewName {...}

Finally you need to run the Script, this can be done in PowerGUI with the F5 key, or you can do it from the command line by browseing the the folder and typing:


The .\ is important, as this is how PowerShell knows that this is a script that it should run.

Powershell scripts can be a bit daunting at first, but you will find that with a bit of practice, you can do almost anything with them.

share|improve this answer

Use a semicolon to chain commands in powershell:

cd "C:/users/..."; Dir | -Rename-Item -NewName {...}

(from How do I run multiple commands on one line in Powershell?)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .