I am basically trying to implement this line in Windows Batch :
cp */win/lib/*.dll ./bin
copy, xcopy, robocopy
FOR loop may feel like overkill, but we're talking about batch here, so why not simply be happy that there is a way to do what you want at all...
:) I know of no other possibility to do this (apart from using external tools). Note that backslashes in the directory mask need to be doubled for regex use in
FINDSTR, which is done in line 4. The caret
^ for the negating character class needs to be escaped twice since it is interpreted twice.
Edit: Correction to not include
.dlls in subdirectories of
@ECHO OFF SET dirmask=\win\lib SET extension=.dll SET regex=%dirmask:\=\\%\\[^^^^\\]*\%extension%$ FOR /F "tokens=*" %%G IN ('DIR /S /B ^| FINDSTR /R "%regex%"') DO COPY %%G .\bin