Skip to content

Instantly share code, notes, and snippets.

@TomK32
Last active December 10, 2015 08:10
Show Gist options
  • Save TomK32/8a61b74026d42b7a2569 to your computer and use it in GitHub Desktop.
Save TomK32/8a61b74026d42b7a2569 to your computer and use it in GitHub Desktop.
A few lines to extract a downloaded album from bandcamp into nice folders
#!/bin/env ruby
# (C) 2015 Thomas R. Koll, <info@ananasblau.com>
# licensed under WTFPL http://www.wtfpl.net/
# Usage: Download gist, put it into your bin directory, chmod it to executable and simply pass the zip files as argument
# the export command is optionally, you might want to change it in the script
# export bandcamp_target_dir='/data/music/'; bandcamp-extractor.rb ~/Downloads/bandcamp/*zip
target_dir = ENV['bandcamp_target_dir'] || '/data/music'
ARGV.each do |filename|
current_dir = target_dir
dirs = filename.split('-').map(&:strip).map{|f| f.gsub(/\.zip/i, '')}
dirs.each do |dir|
current_dir = [current_dir, dir].join('/')
if !Dir.exist?(current_dir)
Dir.mkdir(current_dir)
end
end
system('unzip "%s" -d "%s"' % [filename, current_dir])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment