I'd be very careful - look closely at your COUNT. If you have 11 LOCKBOX*.txt files that pass the attributes test, then the response from your code should be 4
.
The code you have should produce 4
because you/ve omitted the /f
from your FOR, so it evaluates the 'dir
, a/d
... and skips the double-quoted item (I've no idea why it skips the double-quoted item).
If you use FOR /F
in its place, you'd land up with 16
because the output of the dir
command includes 5 non-empty lines - 3 in the header and 2 in the summary.
If you try
for /f %%a in ('dir /B /a-d /a-h /a-s "\\ip_of_server\Directory\LockBox*.txt"') do set /a count+=1&echo %%a
then your count should be correct and you'll get the filename being displayed as well.
If you only want the count, you could also try
for /f %%a in ('dir /a-d /a-h /a-s "\\ip_of_server\Directory\LockBox*.txt"^|find "File(s)"') do set count=%%a