Reputation: 41
I have just written some "code" in Batch to show how many songs are in my library. So far, what I have is this:
F:
cd Music
set /A music=0
for /F %%i in ('dir /B /A-d') do set /A music=music+1
echo There are %music% Audio-Files in your library.
The problem is that this code counts all of the files, even if there's a JPEG or something else in it. But now I want to specify the output by filetypes. How can I get this code to output something like:
"There are (number) Audio-Files in your library. (number) files are in mp3, (number) files are in WAV"
and so on.
Is this possible with this type of commands or do I have to re-write all of this? I hope you understand what I mean.
Many Thanks in advance! :)
Upvotes: 3
Views: 225
Reputation: 57322
dir supports wildcards (* - replaces this with every string) and you can put more than one filter for them:
F:
cd Music
set /A music=0
for /F %%i in ('dir /B /A-d *mp3 *flac') do set /A music=music+1
echo There are %music% Audio-Files in your library.
Upvotes: 1