Created
August 15, 2014 10:09
-
-
Save squarefrog/8bb19b0e1edfd1a48d63 to your computer and use it in GitHub Desktop.
Recursively scans the supplied director and prints filenames alongside bitrates
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
| #!/usr/bin/ruby | |
| # Recursively scans the supplied director and prints filenames alongside | |
| # bitrates | |
| # Usage: | |
| # ./bitrate_scanner.rb path/to/folder/to/scan/recursively | |
| # [sudo] gem install ruby-audioinfo | |
| require "audioinfo" | |
| def print_header(file) | |
| dirname = File.dirname(file) | |
| if @olddirname != dirname | |
| separator = "=" * dirname.length | |
| puts "\n\n\n#{separator}\n#{dirname}\n#{separator}\n\n" | |
| @olddirname = dirname | |
| end | |
| end | |
| def scan_folder(path) | |
| Dir.glob("#{path}/**/*.{m4a,mp3}") do |file| | |
| print_header(file) | |
| AudioInfo.open(file) do |info| | |
| filename = File.basename(file) | |
| puts "#{filename} ( #{info.bitrate} kbps )" | |
| end | |
| end | |
| end | |
| @olddirname = "" | |
| path = ARGV[0].chomp("/") | |
| scan_folder(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment