Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell Script to Copy Files If Folder Exists

$
0
0

Hi All,

I'm doing a data migration and need to achieve the following:

Enumerate the contents of a source directory (example G:) with Get-ChildItem. Every child item will be a folder.

For each of the folders there, check if a folder of the same name exists in a destination folder (example H:).

If the folder in G: also exists in H:, copy the files from one folder to the other using robocopy.

If the folder in G: doesn't exist in H:, skip to the next child item.

I know the basics of cmdlets and scripting in PS, and that I'll probably need to use test-path and foreach, however I'm not sure how I'd cobble these all together to get what I need.

Any advice would be great!

Thanks,

B


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>