Grzenio
Grzenio

Reputation: 36639

Looping over files in subfolders matching a pattern in Windows CMD prompt

I am trying to find all files matching the wildcard *\dev\*\*\*\Results_local.xml in a cmd script, but I failed. I tried:

for %%f in (*\dev\*\*\*\Results_local.xml) do (
echo %%f
)

but it doesn't return any results. What should I do instead?

Upvotes: 0

Views: 116

Answers (1)

Magoo
Magoo

Reputation: 79982

dir /s/b /a-d Results_local.xml |findstr /i /b /r ".*\\dev\\.*\\.*\\.*\\"

should give you a results list.

for /f "delims=" %%f in (
 'dir /s/b /a-d Results_local.xml ^|findstr /i /b /r ".*\\dev\\.*\\.*\\.*\\"'
) do echo %%f

should apply the results to %%f one-by-one.

Upvotes: 2

Related Questions