Old 10-29-2015, 03:50 PM   #1
acintya
Human being with feelings
 
Join Date: Sep 2010
Posts: 281
Default How to delete all empty tracks?

How to delete all empty tracks (the ones which have no vsts on the chain and are totally empty)?

i found something but i dont know how i setup this?

https://stash.reaper.fm/v/25407/Delet...s.ReaperKeyMap


please help
acintya is offline   Reply With Quote
Old 10-29-2015, 04:47 PM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
Default

The ReaperKeyMap file you found binds an action called "Xenakios/SWS: Select tracks with no items" from the SWS extension to a keyboard key. To use it, click on the "Import/Export" button in the Action List. It doesn't actually delete anything or check if there are any FX on the tracks, though.

Here's a short lua script I just wrote which deletes every empty (no items, no FXs, no envelopes) unarmed tracks found in the project:

Code:
-- delete_empty_tracks.lua v0.1 by Christian Fillion (cfillion)

reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()

local track_index, track_count = 0, reaper.CountTracks()
local bucket, bucket_index = {}, 0

while track_index < track_count do
  local track = reaper.GetTrack(0, track_index)

  local fx_count   = reaper.TrackFX_GetCount(track)
  local item_count = reaper.CountTrackMediaItems(track)
  local env_count  = reaper.CountTrackEnvelopes(track)
  local depth      = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
  local is_armed   = reaper.GetMediaTrackInfo_Value(track, "I_RECARM")

  if fx_count + item_count + env_count + math.max(depth, 0) + is_armed == 0 then
    bucket[bucket_index] = track
    bucket_index = bucket_index + 1
  end

  track_index = track_index + 1
end

if bucket_index > 0 then
  local dialog_btn = reaper.ShowMessageBox(
    string.format("Delete %d empty tracks?", bucket_index),
    "Confirmation", 1
  )

  if dialog_btn == 1 then
    local track_index = 0

    while track_index < bucket_index do
      reaper.DeleteTrack(bucket[track_index])
      track_index = track_index + 1
    end
  end
end

reaper.Undo_EndBlock("Delete Empty Tracks", 1)
reaper.PreventUIRefresh(-1)
https://raw.githubusercontent.com/cf...pty_tracks.lua

Save this this in a .lua file and import it in REAPER's Action List (click on the "Load" button right to "ReaScript"). You will see it appear in the list. Double-click on it to execute the script (you can also bind a keyboard shortcut to it if you want).
cfillion is offline   Reply With Quote
Old 10-30-2015, 11:39 AM   #3
acintya
Human being with feelings
 
Join Date: Sep 2010
Posts: 281
Default

Thanks, you have some skills. It works. this is very useful for large experiment projects with more than 150 tracks

fast cleanup.

one offtopic question:

why does this SWS command work anymore in the new reapers?

SWS/S&M: Close all floating FX windows

SWS/S&M: Close all floating FX windows, except focused one

when you have 10 vts open this is really helpful, so that you can minimize all VSTs just with one shortcut/button and you have a clean arranger windows view.... but it does not work anymore

why?

Last edited by acintya; 10-30-2015 at 11:51 AM.
acintya is offline   Reply With Quote
Old 10-30-2015, 12:14 PM   #4
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
Default

They works for me here on REAPER v5.1pre1c with SWS v2.8.1, at least on OS X. If you think there's a bug, you should report it on their issue tracker or maybe here.

cfillion is offline   Reply With Quote
Old 10-30-2015, 01:56 PM   #5
acintya
Human being with feelings
 
Join Date: Sep 2010
Posts: 281
Default

Quote:
Originally Posted by cfillion View Post
They works for me here on REAPER v5.1pre1c with SWS v2.8.1, at least on OS X. If you think there's a bug, you should report it on their issue tracker or maybe here.

hmmmm, thanks.. but it is not that. i figured out now whats the problem ---- it works in reaper 32bit but in reaper 64 you cannot close bridged floating windows (vsts)

any ideas?
acintya is offline   Reply With Quote
Old 12-17-2019, 06:02 PM   #6
LilPuggy
Human being with feelings
 
LilPuggy's Avatar
 
Join Date: Jan 2017
Posts: 5
Default

Quote:
Originally Posted by cfillion View Post

Here's a short lua script I just wrote which deletes every empty (no items, no FXs, no envelopes) unarmed tracks found in the project:
Thanks for sharing this code! Super helpful for me

Made one addition to the .lua script that accounts for sends/receives, it was deleting buss tracks along with empty tracks before.

Here's the updated code:

Code:
-- delete_empty_tracks.lua v0.1 by Christian Fillion (cfillion)

reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()

local track_index, track_count = 0, reaper.CountTracks()
local bucket, bucket_index = {}, 0

while track_index < track_count do
  local track = reaper.GetTrack(0, track_index)

  local fx_count   = reaper.TrackFX_GetCount(track)
  local item_count = reaper.CountTrackMediaItems(track)
  local env_count  = reaper.CountTrackEnvelopes(track)
  local depth      = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
  local is_armed   = reaper.GetMediaTrackInfo_Value(track, "I_RECARM")
  local sends      = reaper.GetTrackNumSends(track, 0)
  local receives   = reaper.GetTrackNumSends(track, -1)


  if fx_count + item_count + env_count + math.max(depth, 0) + is_armed + sends + receives == 0 then
    bucket[bucket_index] = track
    bucket_index = bucket_index + 1
  end

  track_index = track_index + 1
end

if bucket_index > 0 then
  local dialog_btn = reaper.ShowMessageBox(
    string.format("Delete %d empty tracks?", bucket_index),
    "Confirmation", 1
  )

  if dialog_btn == 1 then
    local track_index = 0

    while track_index < bucket_index do
      reaper.DeleteTrack(bucket[track_index])
      track_index = track_index + 1
    end
  end
end

reaper.Undo_EndBlock("Delete Empty Tracks", 1)
reaper.PreventUIRefresh(-1)
__________________
~ one nation under Pug ~

Reaper Tutorials Youtube channel
LilPuggy is offline   Reply With Quote
Old 02-07-2021, 12:13 PM   #7
fbeauvaisc
Human being with feelings
 
Join Date: Nov 2018
Location: Montreal
Posts: 405
Default

Quote:
Originally Posted by cfillion View Post
The ReaperKeyMap file you found binds an action called "Xenakios/SWS: Select tracks with no items" from the SWS extension to a keyboard key. To use it, click on the "Import/Export" button in the Action List. It doesn't actually delete anything or check if there are any FX on the tracks, though.

Here's a short lua script I just wrote which deletes every empty (no items, no FXs, no envelopes) unarmed tracks found in the project:

Code:
-- delete_empty_tracks.lua v0.1 by Christian Fillion (cfillion)

reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()

local track_index, track_count = 0, reaper.CountTracks()
local bucket, bucket_index = {}, 0

while track_index < track_count do
  local track = reaper.GetTrack(0, track_index)

  local fx_count   = reaper.TrackFX_GetCount(track)
  local item_count = reaper.CountTrackMediaItems(track)
  local env_count  = reaper.CountTrackEnvelopes(track)
  local depth      = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
  local is_armed   = reaper.GetMediaTrackInfo_Value(track, "I_RECARM")

  if fx_count + item_count + env_count + math.max(depth, 0) + is_armed == 0 then
    bucket[bucket_index] = track
    bucket_index = bucket_index + 1
  end

  track_index = track_index + 1
end

if bucket_index > 0 then
  local dialog_btn = reaper.ShowMessageBox(
    string.format("Delete %d empty tracks?", bucket_index),
    "Confirmation", 1
  )

  if dialog_btn == 1 then
    local track_index = 0

    while track_index < bucket_index do
      reaper.DeleteTrack(bucket[track_index])
      track_index = track_index + 1
    end
  end
end

reaper.Undo_EndBlock("Delete Empty Tracks", 1)
reaper.PreventUIRefresh(-1)
https://raw.githubusercontent.com/cf...pty_tracks.lua

Save this this in a .lua file and import it in REAPER's Action List (click on the "Load" button right to "ReaScript"). You will see it appear in the list. Double-click on it to execute the script (you can also bind a keyboard shortcut to it if you want).
That's great! Is there a way to tweak it into bypassing the confirmation prompt?

Thanks,
fbeauvaisc is offline   Reply With Quote
Old 02-07-2021, 12:40 PM   #8
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
Default

Quote:
Originally Posted by fbeauvaisc View Post
That's great! Is there a way to tweak it into bypassing the confirmation prompt?
Code:
-- delete_empty_tracks_no_prompt.lua v0.1 by Christian Fillion (cfillion)

reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()

local track_index, track_count = 0, reaper.CountTracks()
local bucket, bucket_index = {}, 0

while track_index < track_count do
  local track = reaper.GetTrack(0, track_index)

  local fx_count   = reaper.TrackFX_GetCount(track)
  local item_count = reaper.CountTrackMediaItems(track)
  local env_count  = reaper.CountTrackEnvelopes(track)
  local depth      = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
  local is_armed   = reaper.GetMediaTrackInfo_Value(track, "I_RECARM")

  if fx_count + item_count + env_count + math.max(depth, 0) + is_armed == 0 then
    bucket[bucket_index] = track
    bucket_index = bucket_index + 1
  end

  track_index = track_index + 1
end

if bucket_index > 0 then
  local track_index = 0

  while track_index < bucket_index do
    reaper.DeleteTrack(bucket[track_index])
    track_index = track_index + 1
  end
end

reaper.Undo_EndBlock("Delete empty tracks", 1)
reaper.PreventUIRefresh(-1)
cfillion is offline   Reply With Quote
Old 02-07-2021, 03:09 PM   #9
fbeauvaisc
Human being with feelings
 
Join Date: Nov 2018
Location: Montreal
Posts: 405
Default

That was fast. Works great thank you!
fbeauvaisc is offline   Reply With Quote
Old 05-20-2023, 05:48 AM   #10
Alez156
Human being with feelings
 
Alez156's Avatar
 
Join Date: Jun 2015
Location: Venezuela
Posts: 350
Default

Quote:
Originally Posted by cfillion View Post
Code:
-- delete_empty_tracks_no_prompt.lua v0.1 by Christian Fillion (cfillion)

reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()

local track_index, track_count = 0, reaper.CountTracks()
local bucket, bucket_index = {}, 0

while track_index < track_count do
  local track = reaper.GetTrack(0, track_index)

  local fx_count   = reaper.TrackFX_GetCount(track)
  local item_count = reaper.CountTrackMediaItems(track)
  local env_count  = reaper.CountTrackEnvelopes(track)
  local depth      = reaper.GetMediaTrackInfo_Value(track, "I_FOLDERDEPTH")
  local is_armed   = reaper.GetMediaTrackInfo_Value(track, "I_RECARM")

  if fx_count + item_count + env_count + math.max(depth, 0) + is_armed == 0 then
    bucket[bucket_index] = track
    bucket_index = bucket_index + 1
  end

  track_index = track_index + 1
end

if bucket_index > 0 then
  local track_index = 0

  while track_index < bucket_index do
    reaper.DeleteTrack(bucket[track_index])
    track_index = track_index + 1
  end
end

reaper.Undo_EndBlock("Delete empty tracks", 1)
reaper.PreventUIRefresh(-1)

This script is super useful, thank you!!

I think it should be included in Reapack.
There is one but this one does a better job
__________________
💙 I run Reapertips.com | 🦋 Reapertips Theme | ☕️ Buy me a coffee
🎸 Modern Metal Songwriting REAPER Template
Alez156 is offline   Reply With Quote
Old 05-20-2023, 07:27 AM   #11
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
Default

Thanks, I've uploaded it to ReaPack as "Remove empty tracks".
cfillion 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 02:12 AM.


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