Count of items matching a search criteria

Started by georgejones314, April 17, 2017, 06:10:21 PM

Previous topic - Next topic

georgejones314

I'm building a simple batch file to compare the total count of files in a directory to the count of files matching -if "$track". if track is present then i have listened to the item (mp3)... and if the total count for track = total items then i have finished the album (directory).

Is there a simple way to count the items that match the -if "$track" criteria?

Thanks
Keith

Sorry if this is obvious, but I spent the appropriate amount of time searching the documentation and forum and came up empty handed.

StarGeek

I think the easiest way would be to pipe the exiftool output into grep (or find for windows) and take the "files read" line that appears at the end. 

exiftool -if "$track" -PlaceholderTag FileOrDir | grep "files read"

Replace grep with find for windows.  I just put "PlaceholderTag" in there as a fake tag to limit the output of exiftool.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

georgejones314

Thanks I'll give it a try and report back.
Keith

georgejones314

The following subroutine worked, but yuch! I hate writing to a temporary file in a batch process. But since I only run this once a year or so, it's not that big a deal.

Thx


:subroutinecompare
REM Search each directory for any podcast having an entry in the track field
REM Compare count of files with track field to total files in directory
REM If equal then the album (directory) is finished (i'm done listening to the album)
setlocal EnableDelayed Expansion
c:\exiftool.exe -if "$track" -L -track !directory!>>c:\temp.m3u8
FOR /F "tokens=1 USEBACKQ" %%i IN (`find "files read" c:\temp.m3u8`) DO (SET done=%%i)
for %%x in (!directory!\*.mp3) do set /a count+=1
if !done! equ !count! echo !folder!>>c:\Finished.m3u8
endlocal
EXIT /b