summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-06-21 00:43:29 +0200
committerRobin Gareus <robin@gareus.org>2019-06-21 00:43:29 +0200
commit8a78b19e1b29ee9661f0bd5967397622a51b0751 (patch)
treebf22c1faf09006eb86b9b184a30daf5d5f7e42e4 /scripts
parent3a2b57771906836b26c93aa7e2055dc2c1047242 (diff)
Add Lua script to sort tracks by name
Diffstat (limited to 'scripts')
-rw-r--r--scripts/_sort_tracks_by_name.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/_sort_tracks_by_name.lua b/scripts/_sort_tracks_by_name.lua
new file mode 100644
index 0000000000..92c9aaaa19
--- /dev/null
+++ b/scripts/_sort_tracks_by_name.lua
@@ -0,0 +1,30 @@
+ardour {
+ ["type"] = "EditorAction",
+ name = "Track Sort",
+ author = "Ardour Lua Taskforce",
+ description = [[Sort tracks alphabetically by name]]
+}
+
+function factory () return function ()
+
+ function tsort (a, b)
+ return a:name() < b:name()
+ end
+
+ local tracklist = {}
+ for t in Session:get_tracks():iter() do
+ table.insert(tracklist, t)
+ print (t:name(), t:presentation_info_ptr():order())
+ end
+
+ table.sort(tracklist, tsort)
+
+ local pos = 1;
+ for _, t in ipairs(tracklist) do
+ t:set_presentation_order(pos)
+ pos = pos + 1
+ end
+
+ tracklist = nil
+ collectgarbage ()
+ end end