Old 10-05-2020, 11:36 AM   #1
JeffreyvR
Human being with feelings
 
Join Date: May 2020
Posts: 19
Default How to delete all unused tracks?

Is there a script to do this? I'm able to do it with the following actions:

Item: Select all items
Script: X-Raym_Select only tracks of selected items.lua
SWS: Select parent(s) of selected folder track(s)
SWS: Toggle (invert) track selection
Delete tracks

But the tracks with receives also get deleted. How to unselect them?
JeffreyvR is offline   Reply With Quote
Old 10-05-2020, 02:16 PM   #2
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

you could insert a small empty item on those tracks that have receives so they won't be selected with your custom action.
heda is offline   Reply With Quote
Old 10-05-2020, 06:15 PM   #3
DarrenH
Human being with feelings
 
Join Date: Mar 2014
Posts: 347
Default

GetTrackNumSends contains the number of sends on a given track



Quote:
Originally Posted by JeffreyvR View Post
Is there a script to do this? I'm able to do it with the following actions:

Item: Select all items
Script: X-Raym_Select only tracks of selected items.lua
SWS: Select parent(s) of selected folder track(s)
SWS: Toggle (invert) track selection
Delete tracks

But the tracks with receives also get deleted. How to unselect them?
DarrenH is offline   Reply With Quote
Old 10-05-2020, 07:47 PM   #4
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 29,260
Default

__________________
Music is what feelings sound like.
karbomusic is offline   Reply With Quote
Old 10-06-2020, 10:41 PM   #5
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default Script

Code:
reaper.Undo_BeginBlock()
for i=reaper.CountTracks(0)-1, 0, -1 do
    track = reaper.GetTrack(0,i)
    if not reaper.GetTrackMediaItem( track, 0 ) then reaper.DeleteTrack( track ) end
end
reaper.Undo_EndBlock("Delete Unused Tracks", -1)
Just put that in a reascript and it will blindly delete all empty tracks... It creates an undo point so you should be able to undo if you are unhappy with the result.... Good luck..

WAIT.. I'm wrong.. this will delete any track that is empty.. which accomplishes the same thing you've already figured out.... You have empty tracks that are receive tracks that you want to prevent from getting deleted? Heda's empty item idea is good... There's probably a way to tell which tracks have receives and which don't via scripting, but that's out of my depth! Good luck...

Last edited by sonictim; 10-06-2020 at 10:47 PM. Reason: I'm wrong
sonictim is offline   Reply With Quote
Old 10-06-2020, 11:06 PM   #6
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,239
Default

Something like this:
Delete empty tracks without receives.

Code:
reaper.Undo_BeginBlock()
for i=reaper.CountTracks(0)-1, 0, -1 do
    local track = reaper.GetTrack(0,i)
    if not reaper.GetTrackMediaItem(track, 0) then 
		local numreceives = reaper.GetTrackNumSends(track, -1) -- get number of receives
		if numreceives == 0 then 
			reaper.DeleteTrack(track) 
		end
	end
end
reaper.Undo_EndBlock("Delete Unused Tracks without receives", -1)
heda is offline   Reply With Quote
Old 10-06-2020, 11:21 PM   #7
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

There it is! I was searching the API for receives, not sends. Ha! Thanks for updating that!!
sonictim is offline   Reply With Quote
Old 10-20-2020, 03:23 AM   #8
JeffreyvR
Human being with feelings
 
Join Date: May 2020
Posts: 19
Default

Quote:
Originally Posted by heda View Post
Something like this:
Delete empty tracks without receives.

Code:
reaper.Undo_BeginBlock()
for i=reaper.CountTracks(0)-1, 0, -1 do
    local track = reaper.GetTrack(0,i)
    if not reaper.GetTrackMediaItem(track, 0) then 
		local numreceives = reaper.GetTrackNumSends(track, -1) -- get number of receives
		if numreceives == 0 then 
			reaper.DeleteTrack(track) 
		end
	end
end
reaper.Undo_EndBlock("Delete Unused Tracks without receives", -1)
Yes great! Althought I'd like to exclude folders as well
JeffreyvR 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:35 AM.


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