So I'm going to count files in a directory including all subfolders and get a output as a number of how many files it found within the directory. The problem is I want to exclude all the folders that has the name error
. Those files within that folder I do not want to be counted.
Simply...
for /r "\\server\share\folderA" %%G in (*.*) do (
set /A count=count + 1
)
echo %count%
Under folderA there are plenty of subfolders that I'm counting, but also the "error" folders that I do not want to count.
So I'm trying the following...
Create a temp file called exclude.txt
and type error
to that file
if not exist "c:\temp" mkdir "c:\temp" 2>nul
if not exist c:\temp\exclude mkdir c:\temp\exclude 2>nul
echo error> %excludefolder%\exclude.txt
Now I want to combine this somehow. Basically do something like this...
for /r "\\server\share\folderA" %%G in (*.*) EXCLUDE: c:\temp\exclude\exclude.txt do (
set /A count=count + 1
)
But I'm aware this will not work and I'm not sure how to work it out. Does anyone know? Thanks!