0

I have a line of code that looks like this, which loads all immediate directory names into Variable A, then continues on through the rest of the loop.

for /d %%A in (*) do

How can I change this such that it skips over items in a pre-defined IgnoreList? For instance:

IgnoreList: Item 1, Item 2, Item 3...note that some Items will have spaces.

Josh
  • 3
  • 4
  • I should note that I already am searching a list in this batch file for another part of it. The list is implemented as such: Items =(Item1, Item2, Item3), basically defined in a variable. I'd like to use the same idea and change the list within the batch file. – Josh Apr 22 '21 at 02:13

2 Answers2

0
dir /b /ad c:\ |findstr /virxg:exclude.txt

where exclude.txt contains folders to ignore, one per line (wildcards possible with findstr REGEX):

Windows
Users
Program.*
Documents.*

If you want to do something with the results, your for loop could look like:

for /f "delims=" %%a in ('dir /b /ad c:\ ^|findstr /virxg:exclude.txt') do @echo %%a
Stephan
  • 1,548
  • 1
  • 10
  • 10