Files: Powershell command to copy a file to another directory

Posted February 18th, 2010 in file, powershell by dirk adamsky

Okido, here’s my first powershell script (or command line).

The action I want to accomplish is to copy a file to another directory.
I installed powershell v2 on my machine.

To open the powershell prompt you can do next steps:

  • give ‘windows key + r’ (opens ‘Start=>Run’)
  • give ‘powershell’ without the quotes
  • the powershell prompt now opens

When you want to change the working directory give cd followed by the full path, for example ‘cd c:temp’ (without quotes).

After changing the working directory it is time for action.
In ‘c:temp’ I created a file named ‘test.txt’ and a directory called ‘c:temptest’.
The powershell command to copy ‘test.txt’ to the ‘test’ directory is:


copy-item c:temptest.txt c:temptest

The result is that the file test.txt is copied to c:temptesttest.txt.
Instead of using copy-item you can also use the aliases ‘cp’ or ‘cpi’.

Happy scripting.

Best regards,

Dirk Adamsky – Deludi BV