I want to batch save all midi files in a folder to individual tracks.
So browse for folder (or hard set it so you don't need reaper.JS_Dialog_BrowseForFolder) and create file list then open first .mid in list
New project
Save project as midi file name
The bypass dialog is set to split/expand midi to multiple tracks and import tempo map,
then as they are all selected, "Convert active take MIDI to .mid file reference", will save them in the project folder.
Save project
Close project
Loop and open next midi in list
Code:
--Read next midi file in a folder
id = reaper.NamedCommandLookup('_RS5a0b653cebf63c4d590e2261d74a1f036d9d92c6') --Bypass dialog script
reaper.Main_OnCommand(id, 0)
-- New project
-- Save project by midi name
reaper.InsertMedia("C:\\Temp\\next-midi.mid", 1)
reaper.Main_OnCommand(40685, 0) --Convert active take MIDI to .mid file reference
-- Save project
-- Close project
-- Loop
Bypass dialog script
Code:
-- Auto Answer 'MIDI File Import' dialog
-- Start this script before inserting media
function Main()
local hwnd = reaper.JS_Window_FindTop('MIDI File Import', true)
if hwnd then -- get checkbox handles
local chk_box1 = reaper.JS_Window_FindChildByID(hwnd, 0x412)
local chk_box2 = reaper.JS_Window_FindChildByID(hwnd, 0x413)
--local chk_box3 = reaper.JS_Window_FindChildByID(hwnd, 0x414)
-- set checked state of check boxes
reaper.JS_WindowMessage_Send(chk_box1, "BM_SETCHECK", 0x1, 0,0,0) -- 0x0=BST_UNCHECKED -- not checked
reaper.JS_WindowMessage_Send(chk_box2, "BM_SETCHECK", 0x1, 0,0,0) -- 0x1=BST_CHECKED -- checked
-- click OK button
local ok_butn = reaper.JS_Window_FindChildByID(hwnd, 0x1)
reaper.JS_WindowMessage_Send(ok_butn, "0xF5", 0,0,0,0)-- BM_CLICK = 0xF5
return -- Exit script after answering dialog
end
reaper.defer(Main)
end
Main()