Reputation: 79467
I can use dir /s /b *.Tests.*.dll
to recursively find all files that match that pattern, but I need to also find them only if they are in \bin\Debug\
instead of \obj\Debug\
or \bin\Release
.
So I tried this command:
dir /s /b Tests\Unit\*\Debug\bin\*.Tests.*.dll
But it fails with The filename, directory name, or volume label syntax is incorrect.
I couldn't find any previous SO question that addresses this problem but if one exists please point it to me.
Is there any way to achieve the desired result (apply filter on entire path)? My intent is to use the list to run NUnit on each unit test assembly in my project under jenkins using this command from Use NUnit Console Runner to run all tests under a folder
for /f %%f in ('dir .\test\ /b /s *.Test.dll') do nunit-console /nologo /noshadow /framework:net-4.0 /xml:.\test\TestResults.xml "%%f"
On linux I would have used ls -r ... | grep ... | xargs ...
and I'm trying to achieve something similar here.
I only need to apply this additional filter on the parent folders as well. If it's not possible I'll have to use PowerShell.
Upvotes: 1
Views: 2334
Reputation: 80023
FOR /d %%a IN ("%sourcedir1%\*") DO DIR /s /b "%%~a\%sourcedir2%\*.exe" 2>nul
where sourcedir1
is the part of the required path before the \*\
and sourcedir2
the part after.
simply assign each dirname in turn to %%a
and use that as the start point for the second dir
Upvotes: 1
Reputation: 79467
I found DOS batch script with for loop and pipe, and using the idea there I constructed this command:
for /f %f in ('dir /s /b Tests\Unit ^| findstr \\bin\\Debug\\.*\.Tests\..*\.dll$"') do echo %f
No I only need to replace %f
with %%f
for batch files, and I can replace echo %f
with the command to run nunit.
Upvotes: 0