1

I want a single command to retrieve track number (or other metadata) from an audio file using ffprobe.

2

1 Answer 1

2
ffprobe -v error -of csv=s=x:p=0 -show_entries format_tags=track my-file

Worked successfully for mp3, m4a and flac formats using ffprobe version 6.0-full_build-www.gyan.dev.

Run ffprobe file to see all available metadata that you can query by replacing track above.

If you want to zero-pad track numbers (1 -> 01 etc.) and also to turn null tracks into 00:

for file in *; do
  printf '%02d\n' "$(ffprobe -v error -of csv=s=x:p=0 -show_entries format_tags=track "$file")"
done

And if you want null tracks to become 99:

for file in *; do
  printf '%02d\n' "$(ffprobe -v error -of csv=s=x:p=0 -show_entries format_tags=track "$file")" | sed -E 's/00/99/'
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .