Print out file bitrates as table

This commit is contained in:
2024-05-30 00:01:31 +02:00
parent 6787decec6
commit e39f6e9d66

View File

@@ -80,7 +80,10 @@ defmodule FindOldMp3s.Application do
System.halt(0)
end
Enum.each(files, fn file -> IO.puts(file) end)
IO.puts("Running exiftool...\n")
Stream.map(files, fn file -> {get_bitrate(file), file} end)
|> Enum.each(fn {bitrate, path} -> IO.puts("#{bitrate}\t|\t#{path}") end)
end
defp show_exiftool_error() do
@@ -112,4 +115,13 @@ defmodule FindOldMp3s.Application do
""")
end
defp get_bitrate(file) do
System.cmd("exiftool", ["-AudioBitrate", file])
|> elem(0)
|> String.split(":")
|> Enum.at(1, "---")
|> String.trim()
|> String.pad_trailing(8)
end
end