Last active
December 7, 2020 00:11
-
-
Save ggorlen/bf5e70bcf551e1f8068add0698ab5d5a to your computer and use it in GitHub Desktop.
show bitrates of mp3s in a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # show bitrates of mp3s in a directory | |
| use strict; | |
| use warnings; | |
| use feature 'say'; | |
| use File::Find; | |
| use File::Spec::Functions; | |
| use MP3::Info; | |
| my @res; | |
| sub walk { | |
| if (-d $_) { | |
| opendir(DIR, $_) or die "Could not open $_\n"; | |
| while (my $filename = readdir(DIR)) { | |
| if ($filename =~ /\.mp3$/i) { | |
| my $path = File::Spec::Functions::catfile($_, $filename); | |
| my $info = get_mp3info($path); | |
| push @res, [$info->{BITRATE}, $_]; | |
| last; | |
| } | |
| } | |
| closedir(DIR); | |
| } | |
| } | |
| find(\&walk, $ARGV[0] || "."); | |
| @res = sort {$a->[0] <=> $b->[0]} @res; | |
| for my $e (@res) { | |
| say sprintf "%+3s :: %s", $e->[0], $e->[1]; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment