Snippet: Replace Plugin Ids Inside Song.xml

This script basically solves this problem for me. Not too much error checking is done but it works and is much less a hassle than doing it all manually. You may have to adjust the plugin table for your own needs first. In my case the key “m” is the x86 filename and “r” the x64 one. You can also fix plugins with version numbers in the filename for example. The replaced plugin HAS to be preset compatible, otherwise the new song will probably not load correctly. Download the script, since it includes ZIP commandline binaries.

--[[----------------------------------------------------------------------------  
  
 Author : Alexander Stoica  
 Creation Date : 02/03/2012  
 Last modified : 02/04/2012  
  
 Replaces known plugin identifiers in a loaded song and saves the result into  
 a new file.  
  
----------------------------------------------------------------------------]]--  
  
local identifiers = table.create({  
 {m = "Dimension Pro", r = "Dimension Pro x64"},  
 {m = "George Yohng's W1 Limiter", r = "George Yohng's W1 Limiter x64"},  
 {m = "jsCompShaper", r = "jsCompShaper.x64"},  
 {m = "Reverberate", r = "Reverberate-x64"},  
 {m = "FilterBank3 FX", r = "FilterBank3 FX x64"},  
 {m = "FilterBank3 synth", r = "FilterBank3 synth x64"},  
})  
  
--[[code]]----------------------------------------------------------------]]--  
  
local ra = renoise.app()  
local rs = renoise.song()  
  
if os.platform() ~= "WINDOWS" then  
 ra:show_error("This script is for Windows only!")  
 return  
end  
  
local zip = os.currentdir() .. "Bin\\zip.exe"  
local unzip = os.currentdir() .. "Bin\\unzip.exe"  
  
if not io.exists(zip) then  
 ra:show_error("Zip.exe not found!")  
 return  
end  
  
if not io.exists(unzip) then  
 ra:show_error("Unzip.exe not found!")  
 return  
end  
  
local xrns_in = rs.file_name  
local xrns_out = xrns_in:gsub(".xrns$", " [replaced].xrns")  
  
if xrns_in:len() == 0 or not io.exists(xrns_in) then  
 ra:show_error("Load an existing song in Renoise first!")  
 return  
end  
  
if xrns_in:find("[replaced]", nil, true) then  
 if ra:show_prompt(  
 "Warning", "The input file seems already processed! Continue?",  
 {"Yes", "No"}  
 ) == "No" then  
  
 return  
 end  
end  
  
if io.exists(xrns_out) then  
 if ra:show_prompt(  
 "Warning", "The output file already exists! Overwrite it?", {"Yes", "No"}  
 ) == "No" then  
  
 return  
 end  
end  
  
local tmp_in = os.tmpname()  
local tmp_out = tmp_in:gsub("([^/\\]+)$", "Song.xml")  
  
if os.execute(  
 unzip .. " -p -o \"" .. xrns_in .. "\" Song.xml >\"" .. tmp_in .. "\""  
 ) ~= 0 then  
  
 ra:show_error("Unzip failed!")  
 return  
end  
  
if io.exists(tmp_out) then  
 os.remove(tmp_out)  
end  
  
local xml = io.open(tmp_out, "w+")  
  
for line in io.lines(tmp_in) do  
  
 if line:find("PluginIdentifier") or  
 line:find("PluginDisplayName") or  
 line:find("PluginShortDisplayName") then  
  
 for _, v in ipairs(identifiers) do  
 if line:find(v.m, nil, true) and not line:find(v.r, nil, true) then  
 line = line:gsub(v.m, v.r)  
 break  
 end  
 end  
 end  
  
 xml:write(line .. "\n")  
  
end  
  
xml:flush()  
xml:close()  
  
local function copy(source, target)  
 source = io.open(source, "rb")  
 target = io.open(target, "w+b")  
 target:write(source:read("*a"))  
 target:flush()  
 target:close()  
 source:close()  
end  
  
copy(xrns_in, xrns_out)  
  
if os.execute(  
 zip .. " -r -j -9 \"" .. xrns_out .. "\" \"" .. tmp_out .. "\""  
 ) ~= 0 then  
  
 ra:show_error("Zip failed!")  
 os.remove(xrns_out)  
 return  
end  
  
os.remove(tmp_in)  
os.remove(tmp_out)  
  
if ra:show_prompt(  
 "Question", "Load the song now?", {"Yes", "No"}  
 ) == "Yes" then  
  
 ra:load_song(xrns_out)  
end  
---------------------------------------------------------------------[[EOF]]--  

Updated the script… way more robust now and more sane error checking.

Oh very nice. Will give it a try, thanks!

How to use it?) Thanks

The download seems to be lost during the forum software upgrade a while ago, here is a new one:

Thanks!