- Script Code -
dofile(reaper.AZ_GetLuaInitPath())
require("reaper_AZSTOKE_SILVER")
allCount = reaper.AZ_GetMediaTypeCount(0,"")
--Mute Media Delete
for i = allCount-1,0,-1 do
mute = reaper.AZ_GetMediaMute(0,i)
if mute then
reaper.AZ_DeleteMedia(0,i)
end
end
depthList = reaper.AZ_GetTrackDepthList(0)
count = reaper.AZ_GetTrackCountSelect(0,0)
track,trackId = reaper.AZ_GetSelectedTrackFirstInfo(0)
for a = 0,1 do
for i = count-1,trackId,-1 do
allCount = reaper.AZ_GetTrackMediaTypeCount(0,i,"")
trackList = reaper.AZ_GetTrackIdChildList(0,i)
if allCount == 0 and retval == false then
retval = reaper.AZ_DeleteTrackIdSelect(0,i,0)
end
end
count = reaper.AZ_GetTrackCountSelect(0,0)
for i = 0,count-1 do
track = reaper.AZ_GetTrackItemSelect(0,i,0)
for e, value in pairs(depthList) do
if track == depthList[e].Track then
retval = reaper.AZ_SetTrackItemDepth(track,depthList[e].Depth)
end
end
end
end
- Warm Up -
Select the first track you want to start deleting
- Script Detail -
dofile(reaper.AZ_GetLuaInitPath())
require("reaper_AZSTOKE_SILVER")
Enable SILVER API
allCount = reaper.AZ_GetMediaTypeCount(0,"")
Output the number of all media and assign it to allCount
--Mute Media Delete
for i = allCount-1,0,-1 do
Loop backwards from allCount to 0
mute = reaper.AZ_GetMediaMute(0,i)
Get mute information for each media
if mute then
If mute is True (muted), continue below
reaper.AZ_DeleteMedia(0,i)
Delete the Index media of [i]
end
end
depthList = reaper.AZ_GetTrackDepthList(0)
Get the hierarchical information of all tracks in a list and assign it to depthList.
count = reaper.AZ_GetTrackCountSelect(0,0)
Get the total number of tracks and assign it to count
track,trackId = reaper.AZ_GetSelectedTrackFirstInfo(0)
Get the first track and track ID of all selected tracks and assign it to track/trackId
for a = 0,1 do
Loop twice to prevent cases where the hierarchy has changed and deletion has not been possible
for i = count-1,trackId,-1 do
Loop from the number of tracks to the first track
allCount = reaper.AZ_GetTrackMediaTypeCount(0,i,"")
Get the number of media for the specified track ID and assign it to allCount.
trackList = reaper.AZ_GetTrackIdChildList(0,i)
- Get the child track of the specified track ID and assign it to trackList
・If there are no child tracks, return false to retval.
if allCount == 0 and retval == false then
If the track has no media and no child tracks
reaper.AZ_DeleteTrackIdSelect(0,i,0)
Delete a specified track
end
end
count = reaper.AZ_GetTrackCountSelect(0,0)
After deleting, output the number of remaining tracks again
for i = 0,count-1 do
Loop a number of tracks
track = reaper.AZ_GetTrackItemSelect(0,i,0)
Get the track with the specified ID and assign it to track
for e, value in pairs(depthList) do
Loop the number of times equal to the number of hierarchical lists
if track == depthList[e].Track then
If the track matches a track in the hierarchical array
reaper.AZ_SetTrackItemDepth(track,depthList[e].Depth)
Resets the track's hierarchy to its previous state
end
end
end
end