Created
January 15, 2026 01:16
-
-
Save TwitchBronBron/b6b70a5953b5f2a8c77c9fcc64288732 to your computer and use it in GitHub Desktop.
Reaper script to scroll to a track by fuzzy name, with scoring higher for folders tracks starting with the typed text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function selectTrackByPartialName() | |
| local retval, trackName = reaper.GetUserInputs("Jump to Track", 1, "Track name:", "") | |
| if not retval or trackName == "" then return end | |
| trackName = trackName:lower() | |
| local bestMatch = nil | |
| local bestScore = -1 | |
| for i = 0, reaper.CountTracks(0) - 1 do | |
| local track = reaper.GetTrack(0, i) | |
| local _, name = reaper.GetSetMediaTrackInfo_String(track, "P_NAME", "", false) | |
| local nameLower = name:lower() | |
| local pos = nameLower:find(trackName, 1, true) | |
| if pos then | |
| local score = 0 | |
| -- Exact match gets highest score | |
| if nameLower == trackName then | |
| score = 10000 | |
| -- Match at start of name is second best | |
| elseif pos == 1 then | |
| score = 5000 - #name -- Shorter names rank higher | |
| -- Match after underscore or space (word boundary) | |
| elseif nameLower:sub(pos-1, pos-1):match("[_%s]") then | |
| score = 3000 - #name - pos | |
| else | |
| -- Other matches: prioritize by position and length | |
| score = 1000 - pos - #name | |
| end | |
| -- Boost score for group/folder tracks | |
| local flags = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH") | |
| if flags == 1 then | |
| score = score + 20000 -- Group tracks get priority | |
| end | |
| if score > bestScore then | |
| bestScore = score | |
| bestMatch = track | |
| end | |
| end | |
| end | |
| if bestMatch then | |
| reaper.SetOnlyTrackSelected(bestMatch) | |
| reaper.SetMixerScroll(bestMatch) | |
| reaper.Main_OnCommand(40913, 0) -- Scroll vertically to selected track | |
| else | |
| reaper.ShowMessageBox("Track not found", "Error", 0) | |
| end | |
| end | |
| selectTrackByPartialName() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment