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

3 gold badges37 silver badges56 bronze badges

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 }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 }
91 gold badges54 silver badges81 bronze badges

Questions tagged [xcopy]
xcopy is a Windows command to copy all files, directories, and subdirectories from a specified path to a target directory
Is there a way to use xcopy, robocopy or batch, to copy and sort files
save xcopy error message in a variable in powershell
Not Sure How to Proceed
In Windows copy a set of empty folders to a large number of differently-named subfolders
Default sort order of xcopy
Can’t copy folder with permissions to NAS share
Invalid number of parameters xcopy
XCopy specific txt files in multiple subfolders without subfolder in path

How to batch copy a list of folders and its file contents from a text file into a new folder in windows
why does the list switch allow xcopy to work?
Batch File Unable To Compare Two String Variables
using for loop to copy selected files in directory and subdirectories to new directory with the same structure
How do I write a batch programe to copy a set of folders with same suffix and their files from a server to a client?

Batch File to copy files to new directory while renaming, skipping existing files, and without confirmation



