Copying Files or Folders with Copy-Item Cmdlet Powershell Command
Please open the Command Prompt by simply by typing powershell into Start Menu search box. Right-click Windows PowerShell and select Run as Administrator. The UAC prompt will ask you for your consent. Click yes, and the prompt will open.
Using Copy-Item cmdlet powershell command copy an item from one location to another within a namespace. Copy files and directories with the FileSystem provider or registry keys and registry entries with the Registry provider.
Following is a example of Copy-Item cmdlet command, here’s a command that copies the file Test.txt from the C:\Scripts folder to the C:\Test folder:
If you like to copy all the items in C:\Scripts (including subfolders) to C:\Test folder then simply use a wildcard character, like so:
Following command copies only the .txt files in C:\Scripts to C:\Test:
Following command puts a copy of the folder C:\Scripts inside the folder C:\Test; in other words, the copied information will be copied to a folder named C:\Test\Scripts. Here’s the command:
Incidentally, the -recurse parameter is absolutely crucial here; leave it out and a Scripts folder will be created in C:\Test, but none of the files and folders in C:\Scripts will be copied to the new location; you’ll create a C:\Test\Scripts folder, but there won’t be anything in it.
Copy-Item Aliases
cpi cp copy
Using Copy-Item cmdlet powershell command copy an item from one location to another within a namespace. Copy files and directories with the FileSystem provider or registry keys and registry entries with the Registry provider.
Following is a example of Copy-Item cmdlet command, here’s a command that copies the file Test.txt from the C:\Scripts folder to the C:\Test folder:
Code:
Copy-Item c:\scripts\test.txt c:\test
If you like to copy all the items in C:\Scripts (including subfolders) to C:\Test folder then simply use a wildcard character, like so:
Code:
Copy-Item c:\scripts\* c:\test
Following command copies only the .txt files in C:\Scripts to C:\Test:
Code:
Copy-Item c:\scripts\*.txt c:\test
Following command puts a copy of the folder C:\Scripts inside the folder C:\Test; in other words, the copied information will be copied to a folder named C:\Test\Scripts. Here’s the command:
Code:
Copy-Item c:\scripts c:\test -recurse
Incidentally, the -recurse parameter is absolutely crucial here; leave it out and a Scripts folder will be created in C:\Test, but none of the files and folders in C:\Scripts will be copied to the new location; you’ll create a C:\Test\Scripts folder, but there won’t be anything in it.
Copy-Item Aliases
cpi cp copy
Last edited by FreeBooter on 18th February 2017, 3:31 am; edited 2 times in total