Reputation: 1997
I am trying to count the total number of jpeg
files located in a folder.
I tried the following:
dir|find /e ".jpeg"
But it returned the following error.
FIND: Invalid switch
I am using Windows-7 64 bit.
Please help.
Upvotes: 1
Views: 1349
Reputation: 5235
The command dir
gives you the count of files at the bottom:
dir *.jpeg
But if you want to do it in a batch file, you can try this:
set count=0 & for %%x in (*.jpg) do @(set /a count+=1 >nul)
echo %count%
Upvotes: 1
Reputation: 57252
Will work if the language settings are in Enlish.For the prompt:
for /f %a in ('dir /a:-d "*.jpeg"^|find /i "file(s)"') do echo %a
For bat file use:
for /f %%a in ('dir /a:-d "*.jpeg"^|find /i "file(s)"') do set count=%%a
echo %count%
Upvotes: 1