powershellcopywildcardcopy-item

Powershell copy with wildcard


The following works fine. Copy-Item -Path C:\Users\Administrator\Desktop\EA\MT4\EA_bot.ex4 -Destination C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\0C2BFA140CA8FBEFEDCADDDEDD61AA24\MQL4\Experts\

However I want to do this for all directories that have the following wild carded, there are many instances: C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\*\MQL4\Experts\

Thank you,

I used * like in linux, that doesn't work in PS


Solution

  • I actually took this further, which might help others. This copies all *.ex4 or all *.ex5 files to ALL instances of MT4 or MT5 at one time with two commands. It copies from my local computer to the VPS servers; I just save the files to MT4 or MT5 locally. I changed the paths just for the fun of it; don't use your desktop, as Microsoft syncs that to their cloud, and it just makes stuff run slow.

    Get-ChildItem -Path "C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\*\MQL4\Experts" -Directory | ForEach-Object { Copy-Item -Path "\\tsclient\C\NOTYOURDESKTOPMICROSOFT\MT4\*.ex4" -Destination $_.FullName }
    Get-ChildItem -Path "C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\*\MQL5\Experts" -Directory | ForEach-Object { Copy-Item -Path "\\tsclient\C\NOTYOURDESKTOPMICROSOFT\MT5\*.ex5" -Destination $_.FullName }
    

    enter image description here