So, the folder structure looks like this:
- Sourcefolder
- file1.txt
- file1.doc
- Subfolder1
- file2.txt
- file2.doc
- SubSubFolder
What I want to do is copy all .txt files from folders whose (folders) names contain eng to the destination folder. Just all the files inside the folder are not a file structure.
What I used:
$dest = "C:\Users\username\Desktop\Final"
$source = "C:\Users\username\Desktop\Test1"
Copy-Item $source\eng*\*.txt $dest -Recurse
The problem is that it only copies .txt files from each parent folder, but not subfolders.
How to include all subfolders in this script and save the eng name check? Can you help me?
I am talking about PowerShell commands. Should I use robocopy?
source
share