Also, kindly go through the following thread:
Copy files to subfolders using powershell

Hi All, I am trying to figure out why the script line below does not work as what I am trying to do is to copy a bunch of text files to sub-folders under a folder above.. for example, I want to copy to c:\temp\plugins\ and then have the script copy to every sub-folder
Copy-Item -Path "C:\TEMP\source\" -Destination "C:\Temp\Plugins" -Recurse -Force -Filter "*.txt"
Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Client for IT Pros | User experience | Other
2 answers
Sort by: Most helpful
-
-
MotoX80 36,291 Reputation points
2022-12-03T16:43:12.78+00:00 Given this...
C:\Temp\source\Subfolder1\New OpenDocument Text.txt
Then this command...
Copy-Item -Path "C:\TEMP\source\" -Destination "C:\Temp\newfolder\" -Recurse -Force -Filter "*.txt"
Will produce...
C:\Temp\newfolder\source\Subfolder1\New OpenDocument Text.txt
And this command....
Get-ChildItem -Path "C:\TEMP\source\" -directory | foreach {Copy-Item -Path $_.fullname -Destination "C:\Temp\newfolder\" -Recurse -Force -Filter "*.txt"}
Will produce...
C:\Temp\newfolder\Subfolder1\New OpenDocument Text.txt
If you want something different, then you will need to explain what you are looking for.