File Copy

I have two folders Folder1 and Folder2 in C drive. Folder1 has few files which needs to be copied to Folder2. Also, after copy of each file from folder1 to folder2, the files can be moved to another folder called ‘Backup’. The point is - this needs to be done by looping each file in the folder. Can you please guide me on this? I am currently using the below script for this, but this gives an error

$CopyFrom = “C:\Folder1”
$CopyTo = “C:\Folder2”

Get-ChildItem -Path $CopyFrom -Exclude ControlFile | ForEach-Object -Process {Copy-Item $File -Destination $CopyTo }

If you want to deliver a professional copy job you can use robocopy … it’s specially made for. :wink:

robocopy “C:\Folder1” “C:\Folder2”  /XF “ControlFile
But if you need to use Powershell you can make your life easier like this:
Get-ChildItem -Path “C:\Folder1” -Exclude “ControlFile” | Copy-Item -Destination “C:\Folder2”

Hi Olaf,

Thanks for your response. I understand that simple child-item / copy-item combination would work.

Thanks again!