Implementing Multi-threading/Parallel processing in script

Joined
Jan 10, 2022
Messages
2,432
Reaction score
1,308
I have this simple script that allows me to copy and paste items in a different folder while also changing their name in windows Powershell.

Code:
$destfolder = '.\destfolder\'
get-childitem -Recurse -File .\srcfolder\ | Foreach-Object {
    $newname = $_.name
$newname = $_.directory.parent.name + '-' + $_.directory.name + '-' + $_.name
Copy-Item -Path $_.FullName -Destination (Join-Path $destfolder $newname) -Verbose
}

I'm wondering how to add multi-threading/parallel processing and maybe robocopy if possible to make it go faster.
 
  • Like
Reactions: Ral

Ral

F
Administrator
Bald AF
Joined
Apr 27, 2021
Messages
2,009
Reaction score
1,655
Location
Unknown
It's ok, Stackoverflow and reddit got me what I needed. your fine.:yousmart
the_key_angle-1536x1152.jpeg
 
Top