Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lyjia/6abd0679a5e8b22a449ab18052652fb2 to your computer and use it in GitHub Desktop.
Save lyjia/6abd0679a5e8b22a449ab18052652fb2 to your computer and use it in GitHub Desktop.
Very simple script for extracting Reverb.com Drum Machines The Complete Collection to a more sane and useful folder structure, without all the redundant verbiage and better more-useful filenames
#!/usr/bin/env ruby
# Very simple script for extracting Reverb.com Drum Machines The Complete Collection
# to a more sane and useful folder structure, without all the redundant verbiage and better more-useful
# filenames
#
# To run this:
# 1) Extract the provided zip into a folder
# 2) Extract all those subzips into their own folders (be sure to target the root folder as they have
# their own subfolders)
# 3) (Optional) Use Bulk Rename Utility to strip away the words "Reverb" from the prefix and "Sample Pack"
# from the suffix of each folder name. (This will make the acronyms in the filenames simpler as it derives
# them from the parent folder name
# 4) Run `ruby {this file name}` at a command prompt
require 'fileutils'
DO_IT = true
def move(oldpath, newpath)
$stderr.puts("... moving <#{oldpath}> to <#{newpath}>")
if DO_IT
FileUtils.mv(oldpath, newpath)
end
end
def copy(oldpath, newpath)
$stderr.puts("... copying <#{oldpath}> to <#{newpath}>")
if DO_IT
FileUtils.cp(oldpath, newpath)
end
end
def rmfolder(path)
$stderr.puts("... deleting #{path}")
if DO_IT
FileUtils.rmtree(path)
end
end
basepath = Dir.pwd
Dir.glob("*").select {|f| File.directory?(f) && "__MACOSX" != f}.each do |f|
Dir.chdir(File.join(basepath, f))
thispath = Dir.pwd
$stderr.puts "================================================================\nNOW ON: #{thispath}\n================================================================"
Dir.glob("*").select {|g| File.directory?(g) && "__MACOSX" != g}.each do |g|
Dir.chdir(thispath)
case g
#rename the ableton project folder
when /Ab[el]{2}ton Project$/i
Dir.chdir(thispath)
move(File.join(thispath, g), File.join(thispath, "ableton"))
#copy the audio files to base folder and rename
when /(Audio files)|(_Audio)$/i
Dir.chdir( File.join(thispath, g) )
subpath = Dir.pwd
Dir.glob("**/*.wav").each do |wav|
oldwav = File.basename(wav).gsub("Reverb ", "")
oldwav = oldwav.gsub(" Sample Pack", "")
instr, remain = oldwav.split("_")
newinstr = instr.scan(/([A-Z0-9])/).map {|x| x[0]}.join
newwav = [newinstr, remain].join("_")
move(File.join(subpath, wav), File.join(thispath, newwav))
end
rmfolder(subpath)
#copy the image files out and copy one to folder.jpg
when /Images$/i
Dir.chdir( File.join(thispath, g) )
subpath = Dir.pwd
Dir.glob("*.jpg") do |jpg|
if jpg =~ /SQ/
copy(File.join(subpath, jpg), File.join(thispath, "folder.jpg"))
end
move(File.join(subpath, jpg), File.join(thispath, jpg))
end
rmfolder(subpath)
#copy license agreement to base folder
when /Licensing Agreement$/
Dir.chdir( File.join(thispath, g) )
subpath = Dir.pwd
Dir.glob("*.pdf") do |pdf|
move(File.join(subpath, pdf), File.join(thispath, "license.pdf"))
end
rmfolder(subpath)
when /ableton$/
$stderr.puts("ignoring ableton")
else
raise "Got something else for #{g}!"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment