Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ruby script to extract Renoise version info from xrns file
#!/usr/bin/env ruby
require 'fileutils'
An xrns file is just a zip file with a special file extension.
That archive holds a number of files. One of these is Song.xml.
This XML has a root element with an attribute named 'doc_version'
<RenoiseSong doc_version="63">
This version seems to differ with each Renoise release.
This script attempts to grab and parse Song.xml, inspect that attribute,
and report back a Renoise version number.
So far it's only been run on Windows 10 and assumes you have 7z.exe
installed and on your path
There are pure-ruby zip libraries, but they can be a pain in the butt.
It's kinda hacky; feel free to make it super-awesome.
Add more doc_version => renoise_version mappings as you learn them.
James Britt / Neurogami
Now go listen to my music and buy my albums for all your friends and family:
RE = /(doc_version=")(.+)(".*)/
TMP = '_tmp'
# h/t
4 => 1.8,
9 => 1.9,
10 => 1.9.1,
14 => 2.0,
15 => 2.1,
21 => 2.5,
22 => 2.6,
30 => 2.7,
37 => 2.8,
54 => 3.0,
63 => 3.1
xrns = ARGV.shift
if !xrns
warn "Usage: #{__FILE__} <path to xrns file> [-c]"
warn "The optional -c arg will clean up the tmp folder created when extracting the song info."
unless File.exist? xrns
warn "Cannot find '#{xrns}'"
unless xrns =~ /\.xrns$/
warn "'#{xrns}' is not an xrns file"
unless File.exist? TMP
Dir.mkdir TMP
FileUtils.cp xrns, TMP
Dir.chdir(TMP) do
if File.exist? 'Song.xml'
FileUtils.rm_rf 'Song.xml'
cmd = %~7za.exe x "../#{xrns}" Song.xml ~
warn cmd
warn `#{cmd}`
lines = IO.readlines 'Song.xml'
root = lines[1]
m = RE.match root
renoise_version = VERSIONS[m[2]]
puts '.' * 90
if renoise_version
puts "'#{xrns}' was made using Renoise #{renoise_version}"
puts "Sorry. Do not have any info for doc_version #{m[2]}"
if ARGV.first =~ /-c/
FileUtils.rm_rf TMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment