I've got a folder with a lots of installation files inside. I would like to take some of these (found by given pattern) and mirror them to the flash drive.
Source:
D:\ccleaner124.exe
D:\dfc221.exe
D:\abc.exe
Destination:
H:\ccleaner123.exe
H:\dfc221.exe
Pattern: (stored directly in the script or at some .txt file)
D:\ccleaner*.exe
D:\dfc*.exe
Result:
Source: unchanged
Destination:
H:\ccleaner124.exe // deleted 123 as it had lower version number in pattern [a-zA-Z_-]*([0-9]*) and copied 124 instead
H:\dfc221.exe // current, so kept the same as it was (no copy)
I looked up the Copy-Item function properties, but I haven't found anything like "mirror" parameter there. Is it even possible to do this with Power Shell?