In the daily data processing task, we always need to copy or move files from multiple source place to one destination folder. In this blog, I’ll show you how to do those task quickly and easily via PowerShell.
I am using below code to move all csv files under Archives folder to Source folder. Archives folder has more than thousands sub-folders.
get-childitem –path e:\archives\*.csv -recurse | move-item -destination d:\source
Get-ChildItem by default only can get the items in one or more specified folder, to perform sub-folders copy and move , we need to user parameter -recurse .
Pip the result
To perform loop copy or move, we need to pipe (|) the recurse result first, then we can use move-item and copy-item cmdlets to do copy or move.