0

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

2
  • 1
    To be clear: the wildcarded `C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal*\MQL4\Experts` is the SOURCE, right? you want to copy files FROM those directories to... whenever you need, is that correct? Commented Jan 12, 2024 at 8:32
  • Best to use XCOPY which is a cmd.exe command and will also work in Powershell. To get more info open a cmd.exe window and type >Help XCOPY. Commented Jan 12, 2024 at 10:06

2 Answers 2

0

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\

Sign up to request clarification or add additional context in comments.

1 Comment

Dead on! Thank you so much, such a time saver!
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.