I was trying to run below bat file which gives me number of files present in a folder, i was getting the count as per the files but if there is no files i am getting "File Not Found"
Count is 0 and which is okay, but i want to suppress "File Not Found"
Script:
@echo off
setlocal enabledelayedexpansion
@echo off
set c2=0
echo Folder,NoOfFiles
for /f "tokens=*" %%x in ('dir /s /a /b "D:\Flow\Flow1\Flow2\Flow3\NGR*.txt"') do set /a c2+=1
echo.NGR,!c2!
Result:
Folder,NoOfFiles
File Not Found
NGR,0
Press any key to continue . . .
I was trying to use 2>nul but that was also not working
Can someone please help me to get the solution, what can be done here?