From 99724786ca7e6f4f6463f8806d512cf32ea54030 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 22 Oct 2026 13:21:14 -0400 Subject: [PATCH] id3-album.rb: fail early if no .mp3 files found --- id3-album.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/id3-album.rb b/id3-album.rb index baa5aba..f535b2d 100755 --- a/id3-album.rb +++ b/id3-album.rb @@ -3,6 +3,12 @@ # Install: kid3-common $stdout.sync = true +files = Dir.glob("*.mp3").sort + +if files.empty? + $stderr.puts "No .mp3 files found" + exit 1 +end $stdout.write("Artist: ") artist = gets.chomp @@ -13,7 +19,6 @@ album = gets.chomp $stdout.write("Year: ") year = gets.chomp -files = Dir.glob("*.mp3").sort files.each do |file| if file =~ /^(\d+)\s*(.*)\.mp3$/ track_number, title = $1.to_i, $2