Dup Ver Goto 📝

AutoRenameTakes

To
32 lines, 165 words, 1277 chars Page 'AutoRenameTakes' does not exist.

The purpose here is to take all the items on a track, named mytrack, and rename them to something of the form myproject_mytrack_001 where 001 is an incrementing counter.

Having sorted through tracks from an old sample CD, categorised them by moving them to a relevant track (e.g. hits or loops), I wanted to automatically name them e.g. loops_001. This script only works when each item has only one take.

To then mass export, you just select all the times, open the render window, and select selected items and use the wildcard $item in the render file name.

The Code

local prefix = "samplecdname"

local ntracks = reaper.GetNumTracks()

for i = 0,ntracks-1 do
  local track = reaper.GetTrack(0,i)
  local ret, trname = reaper.GetTrackName(track)
  local nitems = reaper.GetTrackNumMediaItems(track)
  for j = 0,nitems-1 do
    local item = reaper.GetTrackMediaItem(track,j)
    local take = reaper.GetTake(item,0)
    local ret, name = reaper.GetSetMediaItemTakeInfo_String(take,"P_NAME","",false)
    local newname = prefix.."_"..trname.."_"..string.format("%03d",j) -- fine if <1000 items per track
    reaper.GetSetMediaItemTakeInfo_St?ring(take,"P_NAME",newname,true)
  end
end

Render Window