I this issue... but since there was no solution, I made my own:
Code:
-- MF_Rename active takes to source name
-- M Fabian, v0.1, November 2021
local rpr = reaper
-- Prevent UI refresh
-- For each selected item
-- -- Get the active take
-- -- Get the source name (strip the path)
-- -- Rename take to source name
-- Enable UI refresh, Update arrange view
local function SplitFileName(fname)
-- Returns the Path, Filename, and Extension as 3 values
return string.match(fname, "(.-)([^\\]-([^\\%.]+))$") -- Windows only!
end
local function RenameActiveTake(item)
local take = rpr.GetActiveTake(item)
local source = rpr.GetMediaItemTake_Source(take)
local filename = rpr.GetMediaSourceFileName(source)
local path, srcname, ext = SplitFileName(filename)
rpr.GetSetMediaItemTakeInfo_String(take, "P_NAME", srcname, true)
end
local num_sel_items = rpr.CountSelectedMediaItems(0)
if num_sel_items == 0 then return end
rpr.PreventUIRefresh(1)
for sel_item = 0, num_sel_items-1 do
local MediaItem item = rpr.GetSelectedMediaItem(0, sel_item)
RenameActiveTake(item)
end
rpr.PreventUIRefresh(-1)
rpr.UpdateArrange()
I use this together with Xenakios/SWS: Choose new source file for selected takes... in an action to choose a new file for a take and have the take renamed to the source file name.