Before i do an Audiosuite render on a selection, i like to make a copy of the untreated region so i can revert back later.
It is handy to do this using "copy selection to new playlist". I made a button for that on my StreamDeck.
But, if i have a lot of AudioSuite renders on a track, each copied region makes a new playlist. Resulting in a large number of playlists, containing just one clip. It would be handy if only the first copy makes a new playlist, but the next copied clips would copy to an already existing playlist.
How could i automate that?
- Christian Scheuer @chrscheuer2018-12-08 11:38:11.540Z
You could use code like this as a starting point. This will detect if there's more than one playlist on your current track:
function getPlaylistNames() { var playlistBtn = sf.ui.proTools.selectedTrack.popupButtons.whoseTitle.is('Playlist selector').first; var items = playlistBtn.popupMenuFetchAllItems().menuItems; sf.ui.proTools.appActivateMainWindow(); var playlists = items.filter(function (i) { return i.names[0] === 'Target Playlist' && i.names[1] !== 'Main Playlist' }).map(function (i) { return i.names[1]; }); return playlists; } var playlists = getPlaylistNames(); if(playlists.length == 1) { //We only have our major playlist. Create a new one log('create new playlist'); } else { //We already have more than one playlist. Go to the other one log('go to diff playlist'); //The name of the other playlist will be in playlists[1] }
Fokke van Saane @Fokke
Okay, that If-Then-Else works.
Now, if i want to copy to a new playlist, it is easy. All i have to do islet SF type option+shift+arrow down.
sf.keyboard.press({ keys: 'shift+option+down' });But what is the easiest and/or most elegant way to copy to an already existing playlist?
Christian Scheuer @chrscheuer2018-12-10 21:34:22.813Z
I think the clean way here would be to
Check if playlists.length is exactly 2.
You could even check if the other playlist is correctly named.
Then you can assume that your layout is correct for this track, and just typingsf.keyboard.press({ keys: 'c, shift+option+down, v' });
should probably work. It would be slightly cleaner to use Copy and Paste from the Edit menu like thissf.ui.proTools.getMenuItem('Edit', 'Copy').elementClick();
Fokke van Saane @Fokke
I thought of that route display Playlists, copy clip to it, and folding it back into Waveform view... but i was hoping for a more elegant route.
I have the script pasted below, but there is a mistake in it somewhere. Likely a { or [ or } or }
I am not yet so familiar to the scripting language and have to browse my How To's trough other scripts and forum posts, but i fail a lot as i actually don't know what i am doing in detail.function getPlaylistNames() { var playlistBtn = sf.ui.proTools.selectedTrack.popupButtons.whoseTitle.is('Playlist selector').first; var items = playlistBtn.popupMenuFetchAllItems().menuItems; sf.ui.proTools.appActivateMainWindow(); var playlists = items.filter(function (i) { return i.names[0] === 'Target Playlist' && i.names[1] !== 'Main Playlist' }).map(function (i) { return i.names[1]; }); return playlists; } var playlists = getPlaylistNames(); if (playlists.length == 1) { //We only have our major playlist. Create a new one log('create new playlist'); sf.keyboard.press({ keys: 'shift+option+down' }); } else { //We already have more than one playlist. Go to the other one log('go to diff playlist'); sf.ui.proTools.selectedTrack.trackDisplaySelect({ selectForAllSelectedTracks: true, displayPath: ['playlists'] }); sf.keyboard.press({ keys: 'command+c' }); sf.wait({ intervalMs: 100 }); sf.keyboard.press({ keys: 'semicolon' }); sf.wait({ intervalMs: 100 }); sf.keyboard.press({ keys: 'command+v' }); sf.ui.proTools.selectedTrack.trackDisplaySelect({ selectForAllSelectedTracks: true, displayPath: ['waveform'] }); //The name of the other playlist will be in playlists[1] }
Christian Scheuer @chrscheuer2018-12-11 18:20:08.597Z
I've formatted your code (add three back ticks before and after your lines):
```
, and removed the offending extra]
that you had in there :)Christian Scheuer @chrscheuer2018-12-11 18:23:29.064Z
What I'm not understanding is the shift+option+down. That doesn't create a new playlist here, it navigates to one.
Here I can use shift+option+left to toggle between two playlists if there already are two, and I can use ctrl+quote (Danish keyboard) to create a new playlist.
So I don't fully understand why you're using shift+option+down to create a new playlist and how that can work? I'm no expert in playlist shortcuts as I very rarely use them.Christian Scheuer @chrscheuer2018-12-11 18:25:26.341Z
Ah I see. If I've selected a clip and use option+shift+down it will create a new playlist just with that clip?
I don't think that that's what we want here, since the playlist will then be named like that. I think I'd prefer to go the Ctrl+quote way since that create a new playlist with a.01
suffix, which more closely resembles what you're doing. You could even rename it.original
.Christian Scheuer @chrscheuer2018-12-11 18:32:24.428Z
This code does exactly that.
If a new playlist needs to be created it will create a new playlist and paste your clip onto it.
If an alternative playlist already exists it will go to that one and paste your clip onto it.
Both commands will go back to your original playlist after having done its work.function getPlaylistNames() { var playlistBtn = sf.ui.proTools.selectedTrack.popupButtons.whoseTitle.is('Playlist selector').first; var items = playlistBtn.popupMenuFetchAllItems().menuItems; sf.ui.proTools.appActivateMainWindow(); var playlists = items.filter(function (i) { return i.names[0] === 'Target Playlist' && i.names[1] !== 'Main Playlist' }).map(function (i) { return i.names[1]; }); return playlists; } var playlists = getPlaylistNames(); if (playlists.length == 1) { //We only have our major playlist. Create a new one log('create new playlist'); sf.ui.proTools.getMenuItem('Edit', 'Copy').elementClick(); sf.keyboard.press({ keys: 'ctrl+backslash' }); var win = sf.ui.proTools.windows.whoseTitle.isNullOrEmpty.waitFor({ timeout: 2000 }, 'Could not find window').element; if (!win.exists) throw 'Window didnt come'; win.buttons.whoseTitle.is('OK').first.elementClick(); sf.wait({ intervalMs: 100 }); sf.ui.proTools.getMenuItem('Edit', 'Paste').elementClick(); } else { //We already have more than one playlist. Go to the other one log('go to diff playlist'); sf.ui.proTools.getMenuItem('Edit', 'Copy').elementClick(); sf.keyboard.press({ keys: 'shift+option+left' }); sf.ui.proTools.getMenuItem('Edit', 'Paste').elementClick(); sf.keyboard.press({ keys: 'shift+option+left' }); }
Fokke van Saane @Fokke
Nice! Love you Chris! :-)
I removed the log's as i rather have no screen activity at all in this macro but i can live with the macro that opens window's shortly. I understand SF has it's limits.
Christian Scheuer @chrscheuer2018-12-11 21:03:58.483Z
If you want it completely popup free you could manually create the alt playlist for all the relevant dialogue tracks before starting your work :)
- KKenny Cheng @Kenny_Cheng
Hi Chris,
Sorry I dig out an old post.I use this command alot while recording,
and seems like for some reason it doesn't work properly these days...
Wondering if the update (PT 2020?) changes the shortcut?
I look through a lot documents and not sure where your shortcut "shift+option+left" comes from and what it is now.Thank you
Christian Scheuer @chrscheuer2020-08-06 10:08:44.504Z
According to the manual you now have to use Shift+Home or Shift+End to navigate to the first or last playlist.
Unfortunately, I cannot find the new shortcut for navigating to just next/previous playlist - but in this case, you should only have 2 playlists, so it should work to replace the first "shift+option+left" with "shift+end" and the other with "shift+home" or something like that.
- In reply tochrscheuer⬆:
Varun John @Varun_John
Hey ! Can I get an updated version of this script ? I tried this and it seems to be not working. I also changed Shift+Option+Left to Shift+Home. I get an error in Line 4
Christian Scheuer @chrscheuer2022-04-02 09:35:09.743Z
Hi @Varun_John,
I am busy with the next version of SF these days, but you'll likely get quicker help if you use the new Need help button in SF5 so it can create a new thread, which will make it seen by more people.