Hi, I am attempting to output folders in my library to Json format so that I can stuff album information into Mongo DB. The following outputs invalid Json.
{
"generalInformation":
{
"album": "%album%",
"albumArtist": "%albumartist%",
"genre": "%genre%",
"publisher": "%publisher%",
"copyright": "%copyright%",
"year": "%year%"
},
"encodingSettings":
{
"averageBitRate": "$loop(%_filename_ext%)$puts(Vbitrate,$add($get(Vbitrate),%_bitrate%))$puts(cnt1,$add($get(cnt1),1))$loopend()$div($get(Vbitrate),$get(cnt1)) kbps %_vbr%",
"averageSampleRate": "%_samplerate% khz",
"mode": "%_mode%",
"codec": "%_codec%",
"tagFormat": "%_tag%",
"originalCodecType": "%mediatype%"
},
"totals":
{
"totalSize": "%_total_size%",
"totalTracks": "%_total_files%",
"totalLength": "%_total_time%"
},
"tracks": '[' $loop(%_filename_ext%)
{
"trackNumber": "$num(%track%,2)",
"title": "%title%",
"artists": "%artist%",
"composers": "%composer%",
"length": "%_length%",
"bitRate": "%_bitrate%kbps %_vbr%",
"fileName": "%_filename_ext%",
"fileSize": "%_file_size%"
},
$loopend()']'
}
The issue is the LAST comma. What I need is a way to determine if the script is outputting information on the LAST FILE in the folder and if it is skip the last comma. Does anyone have any guidance here? What I am wondering is if I can conditionally output the comma based on whether or not the script is processing the last file in a folder or not. Is that possible?