The attached export config displays a count of files containing each podcast category (%podcastcategory%). It takes into account multi-value fields.
I use it to find spelling and other errors in the categories.
It's easy to modify for any other tags you may want to count.
Program logic:
- build a master file containing all categories (on the desktop)
- sort the file
- iterate through the file looking for changes one to the next and counting as you go
It leaves a couple of files on the desktop for you to clean up when you're done.
One nagging issue remains: it screws up if the field contains a pipe (|). I haven't figured out yet how to escape those darn pipes in the meta_sep operation.
Note: mostly not my coding. I merely modified some code found on stackoverflow
.mte coding is as follows ------------
$filename($getEnv('USERPROFILE')'\desktop\CategoryCounts.bat',ANSI)
@Echo Off
chcp 1254
if exist "%%USERPROFILE%%\Desktop\taglisting.txt" del "%%USERPROFILE%%\Desktop\taglisting.txt" /q
$loop(%podcastcategory%)
echo>>"%%USERPROFILE%%\Desktop\taglisting.txt" $meta_sep(podcastcategory,$char(13)$char(10)echo>>"%%USERPROFILE%%\Desktop\taglisting.txt" )
$loopend()
@echo off
setlocal disableDelayedExpansion
set "file=%%USERPROFILE%%\Desktop\taglisting.txt"
set "sorted=%%file%%.sorted"
set "counted=%%file%%.counted"
set /a N = 1
REM Define a variable containing a linefeed character
set LF=^
REM The 2 blank lines above are critical, do not remove
sort "%%file%%" >"%%sorted%%"
"%%counted%%" (
set "prev=start"
for /f usebackq^ eol^=^%%LF%%%%LF%%^ delims^= %%%%A in ("%%sorted%%") do (
set "curr=%%%%A"
setlocal enableDelayedExpansion
if /i "!curr!" neq "!prev!" (
if "!prev!" neq "start" echo !n! !prev!
endlocal
set "prev=%%%%A"
set /a N = 1
) else (
endlocal
set /a N += 1
)
)
setlocal enableDelayedExpansion
echo !n! !curr!
endlocal
)
nul move /y "%%counted%%" "%%file%%"
del "%%sorted%%"
"%%USERPROFILE%%\Desktop\taglisting.txt"
CategoryCounts.mte (1.19 KB)