Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the list of files that are getting copied in PowerShell

I am using the PowerShell Copy-Item command to copy a directory with files to another location.

I want to display all the files on the console that are getting copied so that I know the status of the copy command.

like image 921
tusharmath Avatar asked Dec 11 '12 07:12

tusharmath


People also ask

What is Get-ChildItem in PowerShell?

Description. The Get-ChildItem cmdlet gets the items in one or more specified locations. If the item is a container, it gets the items inside the container, known as child items. You can use the Recurse parameter to get items in all child containers and use the Depth parameter to limit the number of levels to recurse.

Does xcopy work in PowerShell?

xcopy is the windows command. It works with both PowerShell and cmd as well because it is a system32 utility command.

How do I use CP in PowerShell?

To copy items in PowerShell, one needs to use the Copy-Item cmdlet. When you use the Copy-Item, you need to provide the source file name and the destination file or folder name. In the below example, we will copy a single file from the D:\Temp to the D:\Temp1 location.


1 Answers

If you just want to see that in console, use the -verbose switch:

copy-item -path $from -destination $to -verbose 

If you want to get a list of files or directories:

$files = copy-item -path $from -destination $to -passthru | ?{$_ -is [system.io.fileinfo]} 
like image 59
Jackie Avatar answered Oct 04 '22 04:10

Jackie