Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionally Copy File

Status
Not open for further replies.

thermidor

Programmer
Nov 28, 2001
123
US
Hi All -

I want to write a PS routine to recursively search a directory. If that search finds files with a certain string of characters ("xyz") in the name, the file should be copied to a target with the directory structure on the source replicated (if it does not already exist) on the target.

I am new to PS and am having trouble breaking down how to approach this in PS. Any suggestions/guidance would be greatly appreciated.

TIA,
Sven
 
Simple answer to my own question:
copy-item H:\PS H:\PS_target -Recurse -Filter "*xyz*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top