I need Robocopy to copy all folders starting with example 6000 to new server. It should also create the folders at the new server in same script. I try something like this: I need Robocopy to copy all folders starting with example 6000 to new server. It should also create the folders at the new server in same script. I try something like this: Can try something like this? Based on what your query is though, should make work?<\/p>\n I get this Get-ChildItem : Could not find a part of the path foreach ($Folder in $Folders) { Start-Process “robocopy” -ArgumentList {$SourcePath, $DestPath /“MIR” /“XO” /“copy:DATS” /“MT:32”}
\n$Source=(Get-Item \\server01\\OldFiles | Where-Object {$.PSIsContainer -and $<\/em>.Name -like “6000*”}).Name
\nForeach ($Source in $Source){
\nrobocopy \\server01\\OldFiles$Source \\Server02\\6000- /MIR /xo /COPY:DATS
\n}
\nBut It takes only what is inside folders starting with 6000 to new server. I need script to create folders also and then copy all insite the folders. Can anyone help?<\/p>","upvoteCount":5,"answerCount":10,"datePublished":"2025-06-02T12:49:42.562Z","author":{"@type":"Person","name":"spiceuser-pc3n","url":"https://community.spiceworks.com/u/spiceuser-pc3n"},"suggestedAnswer":[{"@type":"Answer","text":"
\n$Source=(Get-Item \\server01\\OldFiles | Where-Object {$.PSIsContainer -and $<\/em>.Name -like “6000*”}).Name
\nForeach ($Source in $Source){
\nrobocopy \\server01\\OldFiles$Source \\Server02\\6000- /MIR /xo /COPY:DATS
\n}
\nBut It takes only what is inside folders starting with 6000 to new server. I need script to create folders also and then copy all insite the folders. Can anyone help?<\/p>","upvoteCount":5,"datePublished":"2025-06-02T12:49:42.621Z","url":"https://community.spiceworks.com/t/copy-folders-with-special-names/1211472/1","author":{"@type":"Person","name":"spiceuser-pc3n","url":"https://community.spiceworks.com/u/spiceuser-pc3n"}},{"@type":"Answer","text":"
\nI don’t use robocopy, so this is untested.<\/p>\n$SourceRoot = \"\\\\server01\\OldFiles\"\n$DestRoot = \"\\\\Server02\\OldFiles\"\n\n$Folders = Get-ChildItem -Path $SourceRoot -Directory -Recurse | Where-Object { $_.Name -like \"6000*\" }\n\nforeach ($Folder in $Folders) {\n $SourcePath = Join-Path $SourceRoot $Folder.Name\n $DestPath = Join-Path $DestRoot $Folder.Name\n\n # Create destination folder if it doesn't exist\n if (-not (Test-Path -Path $DestPath)) {\n New-Item -Path $DestPath -ItemType Directory | Out-Null\n }\n\n\n Start-Process \"robocopy\" -ArgumentList {$SourcePath, $DestPath, \"/MIR\" \"/XO\" \"/COPY:DATS\"}\n}\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2025-06-02T14:12:13.648Z","url":"https://community.spiceworks.com/t/copy-folders-with-special-names/1211472/2","author":{"@type":"Person","name":"fallen-it","url":"https://community.spiceworks.com/u/fallen-it"}},{"@type":"Answer","text":"
\nAt line:4 char:12<\/p>\n\n
\nBut if I use this the folders is created but nothing content in all the created folders.
\n$folders = Get-ChildItem \\server01\\OldFiles -filter “6000” -Directory<\/li>\n<\/ul>\n
\n$SourcePath = Join-Path $SourceRoot $Folder.Name
\n$DestPath = Join-Path $DestRoot $Folder.Name<\/p>\n# Create destination folder if it doesn't exist\nif (-not (Test-Path -Path $DestPath)) {\n New-Item -Path $DestPath -ItemType Directory | Out-Null\n}\n<\/code><\/pre>\n
\n}<\/p>","upvoteCount":2,"datePublished":"2025-06-02T14:43:53.187Z","url":"https://community.spiceworks.com/t/copy-folders-with-special-names/1211472/3","author":{"@type":"Person","name":"spiceuser-pc3n","url":"https://community.spiceworks.com/u/spiceuser-pc3n"}},{"@type":"Answer","text":"