0

I have a folder with many subfolders in it. Each of these subfolders may or may not contain a file named "George.txt".

This command (in a batch file)

for /d %%A in (*) do @if not exist "%%~fA\George.txt*" echo %%~fA

finds all the subfolders where "George.txt" doesn't exist and outputs a list in the cmd window like this:

D:\Folder\S1
D:\Folder\S5
D:\Folder\S11

Now I also need to know the total number of subfolders where "George.txt" doesn't exist. Either by appending numbers to each line:

1. D:\Folder\S1
2. D:\Folder\S5
3. D:\Folder\S11

or displaying a total at the end of the list, I have no preference:

D:\Folder\S1
D:\Folder\S5
D:\Folder\S11
Total: 3

Is something like this possible natively? I'm using Win 7 Ultimate x64.

1 Answers1

0

You may try something like this

set /a nCount=0
for /d %%A in (*) do (
  @if not exist "%%~fA\George.txt*" (
    set /a nCount+=1
    echo %%~fA
  )
)
echo Total %nCount% folder(s) found