I'd like to find and copy all the files in a certain directory and all it's sub-directories with a particular name.
I'm using Copy-Item
in Powershell (technet | ss64)
Here's what I have:
Copy-Item `
-Path \\Server\Apps\* `
-Destination C:\ReadMeFiles\ `
-Include *ReadMe.txt `
-Recurse `
-WhatIf
It will grab the following file:
\\Server\Apps\ReadMe.txt
But not:
\\Server\Apps\AppName\ReadMe.txt
Even though I've specified -recurse
How can I get it to travel down in each directory?
Best Answer
My slightly modified answer from this question: Batch File:List all files of a type, rename files, flatten the directory
It does what you want: copies files using wildcard, flattens directory structure, handles filename conflicts. It uses
Get-ChildItem
, asTᴇcʜιᴇ007
suggested.