Copy Files and Folders using PowerShell

#PowerShell #Robocopy #Windows10

Microsoft Windows 10 comes with a very powerful scripting tool called PowerShell. PowerShell is an open source project from Microsoft and it is platform independent. It works on Windows, Linux based systems even on Apple’s MacOS.

If you are interested to know more about PowerShell and what it can do for you to be more productive in your work and personal jobs, please click here


We will be using one of the very useful PowerShell command ROBOCOPY to copy the files from one location to other. Robocopy is even more faster than copying a graphical way.


Syntax of ROBOCOPY

robocopy <Source> <Destination> [<File>[ ...]] [<Options>]

Parameters

Parameters                Description


<Source>          Specifies the path to the source directory.

<Destination>            Specifies the path to the destination directory.

<File>             Specifies the file or files to be copied. You can use wildcard characters (* or ?), if you want. If the File parameter is not specified, .\ is used as the default value.

<Options>           Specifies options to be used with the robocopy command.

Example of Robocopy in PowerShell

PS > robocopy C:\<Source Path> C:\<Destination Path> /MIR

Source Path is the path where you have files and folders you want to copy and Destination is the path where you want to paste these files to.

If there is a space in the folder name, enclose the whole path in single quotes (‘’). Moreover, if you copy the path and paste it in PowerShell, sometimes the path contain slash() at the end of the path. Please make sure you remove the slash otherwise, the robocopy command will give an error.

Use Robocopy to copy files on the Remote Computer on the Network

Using robocopy it is also possible to copy the content to a remote destination on the network. Not only this, you can also run multiple robocopy instances to copy files on different locations or different computers.

To copy the files on a remote computer use the following syntax

PS > robocopy C:\<Source Path> \\Server IP Address\C:\<Destination Path> /MIR

Robocopy is powerful command and can do much more than that. PowerShell also has a quite good built in help as well as online.

To use the built in help and to find out all the options can be used with robocopy command,type:

PS C:\> robocopy /?

https://platform.twitter.com/widgets.js

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.