Old 04-13-2023, 03:59 AM   #1
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default Batch MID To Tracks

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()
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 04-13-2023 at 04:05 AM.
MusoBob is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.