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