• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Powershell -get childitem and copy-item

ptjuh

Junior Member
I Hope some one can help me out with this problem.

I want to copy files from a sub sub folder and all the files in that specific folder needs to be copied to one folder.

Like this

driveletter: \FolderA\year\number\ files

What the problem is with this copy is the FolderA and Year (multiple years) everytime is different.

Only the folder Number is always’s the same. And in the number folder are the files that I want.



So I got

driveletter: \FolderA\year14\number\ files
driveletter: \FolderA\year15\number\ files
driveletter: \FolderB\year14\number\ files
driveletter: \FolderB\year15\number\ files
driveletter: \FolderC\year15\number\ files
driveletter: \FolderD\year14\number\ files
(did a space between : \ because getting this :\)

but Foldera is going until zzz

I was trying to do this with powershel but i just see al the files in the folder in folder a and year. So not just the files in Number.

Was using this command :

Get-ChildItem -Recur c: \ -Include *.docx, *.xls, *.pdf | Copy-Item -destination: e: \Number
 
This seems like something you can do at the regular command line. I may be a little rusty!

Code:
for %i in (c:\Folder*) do for %j in (%i\year*) do copy %j\number\* e:\Number
 
It sounds like you want to copy only the files that are in the "number" folder and not any files that may be located in "FolderA", "FolderB", ... or under the "year14", "year15", etc.

If that's the case, you can try this command:

Code:
GCI C:\_Test -Include *.docx, *.xls, *.pdf -Recurse | ? { $_.PSParentPath -like "*\Number" } | Copy-Item -Destination E:\Number
 
It sounds like you want to copy only the files that are in the "number" folder and not any files that may be located in "FolderA", "FolderB", ... or under the "year14", "year15", etc.

If that's the case, you can try this command:

Code:
GCI C:\_Test -Include *.docx, *.xls, *.pdf -Recurse | ? { $_.PSParentPath -like "*\Number" } | Copy-Item -Destination E:\Number

Her, Thats correct I only want to get the files from the folder number.
I will try the code you have send.



Tried it. None of the files where copied? 🙁

@echo off

GCI C:\_ -Include *.docx, *.xls, *.pdf -Recurse | ? { $_.PSParentPath -like "*\numbers" } | Copy-Item -Destination E:\numbers

pause
 
Last edited:
Back
Top