mk-usb-music-disk-for-car: add -s option to show directory sizes

This commit is contained in:
Josh Holtrop 2023-03-03 09:55:50 -05:00
parent f11970fee3
commit 70b07abbae

View File

@ -5,29 +5,41 @@ BASE = "/pegasus/pub/music/artists"
DEST = "/media/josh/JoshMusic" DEST = "/media/josh/JoshMusic"
ARTISTS = <<EOF ARTISTS = <<EOF
Avenged Sevenfold A Perfect Circle
All That Remains
#Avenged Sevenfold
Collective Soul Collective Soul
DevilDriver Dave Matthews Band
Falling in Reverse Days Of The New
#DevilDriver
#Falling in Reverse
Eluveitie
Fear Factory Fear Factory
Fuel Fuel
Godsmack #Godsmack
Hans Zimmer
Incubus Incubus
Lamb of God Lamb of God
Machine Head London Symphony Orchestra
#Machine Head
Matchbox Twenty
Mudvayne Mudvayne
Our Lady Peace
POD POD
Staind Ra
Static-X Rush
System of a Down #Staind
#Static-X
#System of a Down
Tantric Tantric
Taproot Taproot
The Goo Goo Dolls The Goo Goo Dolls
The Offspring The Offspring
Tool #Tool
Trans-Siberian Orchestra Trans-Siberian Orchestra
Trivium Trivium
Volbeat Volbeat
Weezer
EOF EOF
EXCLUDE = <<EOF.split("\n").map(&:chomp) EXCLUDE = <<EOF.split("\n").map(&:chomp)
@ -36,12 +48,23 @@ EOF
require "fileutils" require "fileutils"
artists = ARTISTS.lines.map do |artist|
if artist !~ /#/
artist.chomp
end
end.compact
if ARGV[0] == "-s"
cmd = %w[du -shc] + artists.map {|a| "#{BASE}/#{a}"}
system(*cmd)
exit 0
end
unless Dir.exist?(DEST) unless Dir.exist?(DEST)
$stderr.puts "#{DEST} does not exist" $stderr.puts "#{DEST} does not exist"
end end
ARTISTS.lines.each do |artist| artists.each do |artist|
artist = artist.chomp
Dir.glob("#{BASE}/#{artist}/*").sort.each do |album_dir| Dir.glob("#{BASE}/#{artist}/*").sort.each do |album_dir|
next if album_dir.split("/").any? {|part| EXCLUDE.include?(part)} next if album_dir.split("/").any? {|part| EXCLUDE.include?(part)}
album = File.basename(album_dir) album = File.basename(album_dir)