Powershell copy with wildcard
Powershell copy with wildcard
Loading saved threads...
Scott Bowden · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Scott Bowden
Original post: https://stackoverflow.com/questions/77804908
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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
Quote
Report
Martin Iszac · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Martin Iszac
Original post: https://stackoverflow.com/a/77807708
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Use
Get-ChildItem
to loop over all the directories. You can do this in a one-liner.
Get-ChildItem -Path "C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\*\MQL4\Experts\" -Directory | ForEach-Object { Copy-Item -Path "C:\Users\Administrator\Desktop\EA\MT4\EA_bot.ex4" -Destination $_.FullName }
This will copy the
EA_bot.exe
to
MQL4\Experts\
under any directory in
C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\
Quote
Report
Scott Bowden · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Scott Bowden
Original post: https://stackoverflow.com/a/77870605
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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 }
Quote
Report
Post Reply
Checking account access…