The idea would be for spotting BGs...say I have all locations marked as region groups named "This Location" or "That Location"
Is there a script I could use to change all regions named "This Location" red and all "That Location" blue for example?
Almost like a batch rename but with colors
Linked from:
- samuel henriques @samuel_henriques
Hello Jon,
This should do it.
Set your name-color list on the top of the script.
Add as many as you want. Clip names that are not in the list will be ignored.Make a selection of clips and it will do it for all selected, on all selected tracks.
Hope this is it.
const colorName = { "This Location": { colorBrightness: "Light", colorNumber: 8 }, "That Location": { colorBrightness: "Light", colorNumber: 13 }, }; function getClipName() { sf.ui.proTools.menuClick({ menuPath: ["Clip", "Rename..."] }); const renameWin = sf.ui.proTools.windows.whoseTitle.is("Name").first.elementWaitFor({}, 'Rename Clip Window Not Found.').element; const clipName = renameWin.groups.first.textFields.first.value.invalidate().value; renameWin.buttons.whoseTitle.is("Cancel").first.elementClick(); renameWin.elementWaitFor({ waitType: "Disappear" }, 'Rename Clip Window Failed to Close.'); return clipName; }; /** * @param {string} name */ function setClipColor(name) { if (name in colorName) { sf.ui.proTools.colorsSelect({ colorTarget: "ClipsInTracks", colorBrightness: colorName[name].colorBrightness, colorNumber: colorName[name].colorNumber }); }; }; sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.invalidate(); //Get selected tracks const originalTracks = sf.ui.proTools.selectedTrackNames; //Do for each track. sf.ui.proTools.selectedTracks.trackHeaders.slice().map(track => { //Select track track.trackSelect(); //Scroll track into View track.trackScrollToView(); // Color each selected clip sf.ui.proTools.clipDoForEachSelectedClip({ action: () => { setClipColor(getClipName()) }, onError: "Continue" }) }); //Restore previously selected tracks sf.ui.proTools.trackSelectByName({ names: originalTracks });
- JJon Lipman @Jon_Lipman
Thanks Samuel - I pased the script and replaced your "This Location" and "That Location" with corresponding "1" and "4" as a test and not really sure what happened but here's a video of the screen below...it jumped around onto other tracks and started renaming and trimming.
Any ideas?
samuel henriques @samuel_henriques
Hey Jon,
Thank you for the video it makes it easier to spot what could me wrong.
Didn't see any trimming, not sure about that.
It is actually working as intended, It works on selected tracks and in the video it processed clips on the selected tracks.
Since you have "Link Track and Edit Selection" disabled,
when you made the initial selection it didn't change the selected tracks.
- JIn reply toJon_Lipman⬆:Jon Lipman @Jon_Lipman
Hmmm still not working for me even with all both timeline and track link turned off.
In this video I have only the track selected that contains the regions I want re-colored.
I do 3 things in this video:
- Run the script with the track selected but not the regions
- Run the script with the tracks selected AND the regions
- This is an example of me manually doing what I'm attempting to achieve with this script (just in case I wasn't clear in my description)
samuel henriques @samuel_henriques
Sorry Jon, just found a way it could behave as in the video.
Could you check that the groups and audio are shown in the clip list?Clip list doesn't have to be opened but Audio end Groups must be shown, otherwise pro tools wont open the clip name window, witch we need to know the name of the selected clip.
If it's common you keep these hidden, I can white something to make sure they are shown.
- JIn reply toJon_Lipman⬆:Jon Lipman @Jon_Lipman
Hi Samuel...yes I can confirm that both audio and groups were shown in the clip list...just to be safe I went ahead and checked color, timebase, processing state and file type to match your example but still no luck.
Could this be some minor error on my end that's screwing this up?
I copy pasted your script exactly and only changed the names of the regions to be affected.
- JIn reply toJon_Lipman⬆:Jon Lipman @Jon_Lipman
Ok so this is interesting...just to experiment, I created a brand new project with a single track and tried the script out and as long as I had the regions selected, success!
The original session I was trying this in is a very large session containing about 50gb of audio files and a massive clip bin...is it possible the sheer size of the session is preventing this from working somehow?
- JJon Lipman @Jon_Lipman
Also (although maybe this is how you designed it) it only works across a single track...so even if I selected regions on multiple tracks with all selected, it only applied the color changes to the first track then gave me this error.
22.02.2022 23:18:09.76 [Backend]: Logging error in action (01) TrackScrollToViewAction: Selected track header and track list item does not match. List Name: ''. Header Name: '2'
22.02.2022 23:18:09.76 [Backend]: !! Command Error: Color [user:ckz4kpwnr0005t2101rnyu5v1:ckzykoy260000qj105plz6zei]:
Selected track header and track list item does not match. List Name: ''. Header Name: '2' (Color: Line 41)samuel henriques @samuel_henriques
Will try to figure it. You must make a selection and it will process the clips within the selection. So your test with a selection is the correct one.
samuel henriques @samuel_henriques
AHHH!!! Got it, found two stupid mistakes on the script.
Just updated above, hope this is it.Just to clarify, it will check the name of the clip and color it depending on your list,
all selected clips only on all selected tracks.Hope this was the problem, my apologies.
- JJon Lipman @Jon_Lipman
Hey Samuel...did you update the first script that you posted? I copy pasted that in but I'm having the same results...I'm uploading another video just to be sure you can see what's going on...thanks for your help with this!
samuel henriques @samuel_henriques
I did update, checked your video thank you. What version of pro tools are you on?
Could you try to quit and restart soundFlow please?
samuel henriques @samuel_henriques
if it doesn't work could you check this test script please.
Select a few tracks and run script.
The script will select each track and log its name.sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.invalidate(); //Get selected tracks const originalTracks = sf.ui.proTools.selectedTrackNames; //Do for each track. sf.ui.proTools.selectedTracks.trackHeaders.slice().map(track => { //Select track track.trackSelect(); //Scroll track into View track.trackScrollToView(); log(sf.ui.proTools.selectedTrackNames[0]) });
- In reply tosamuel_henriques⬆:JJon Lipman @Jon_Lipman
Success! I restarted soundflow after updating the script and it's working now...thank you!
BTW - I'm on PT 2021.12.0
samuel henriques @samuel_henriques
Awesome, it looks like soundFlow didn't update the script when you made the new paste.
Keep testing it and let me know how it goes.
samuel henriques @samuel_henriques
Also I made a version that will set the view on the clip list in case they are not enabled. Let me know if you'd like it.
- JJon Lipman @Jon_Lipman
Awesome thanks...I pretty much always have those on in the clip list so it's probably just another step I don't need - so far so good...
So the reason I'm requesting this script is to spot BGs - I'll break a show up into named clips spanning recurring locations. So I'll maybe color all "Jon's House" region groups red. Then I go back and take my 5 minute long "Jon's House" clip group containing all the BG audio for that location and put it under everything red - trim to fit, ungroup and add fades.
- In reply tosamuel_henriques⬆:
Trip Brock @Trip_Brock
Hi Samuel, I came across this thread with the script that you wrote which is very cool and helpul as i'm trying to learn more about this great software! How would I go about modifiying this script slightly so that the clip coloring that the script provides happens on the selected clip names that (start with) or (contain) the text names in the name-color list, as opposed to having to be an exact match? Is this possible? Many thanks!
samuel henriques @samuel_henriques
Hello Trip,
Try this:const colorName = { "Int": { colorBrightness: "Light", colorNumber: 8 }, "Ext": { colorBrightness: "Light", colorNumber: 13 }, "Kitchen": { colorBrightness: "Light", colorNumber: 20 }, }; function getClipName() { sf.ui.proTools.menuClick({ menuPath: ["Clip", "Rename..."] }); const renameWin = sf.ui.proTools.windows.whoseTitle.is("Name").first.elementWaitFor({}, 'Rename Clip Window Not Found.').element; const clipName = renameWin.groups.first.textFields.first.value.invalidate().value; renameWin.buttons.whoseTitle.is("Cancel").first.elementClick(); renameWin.elementWaitFor({ waitType: "Disappear" }, 'Rename Clip Window Failed to Close.'); return clipName; }; /** * @param {string} name */ function setClipColor(name) { const nameInColorName = Object.keys(colorName).filter(color => color.toLowerCase().indexOf(name.split(" ")[0].toLowerCase()) > -1)[0]; if (nameInColorName) { sf.ui.proTools.colorsSelect({ colorTarget: "ClipsInTracks", colorBrightness: colorName[nameInColorName].colorBrightness, colorNumber: colorName[nameInColorName].colorNumber }); }; }; function main() { sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.invalidate(); //Get selected tracks const originalTracks = sf.ui.proTools.selectedTrackNames; //Do for each track. sf.ui.proTools.selectedTracks.trackHeaders.slice().map(track => { //Select track track.trackSelect(); //Scroll track into View track.trackScrollToView(); // Color each selected clip sf.ui.proTools.clipDoForEachSelectedClip({ action: () => { setClipColor(getClipName()) }, onError: "Continue" }) }); //Restore previously selected tracks sf.ui.proTools.trackSelectByName({ names: originalTracks }); }; main();
Trip Brock @Trip_Brock
Hi Samuel, thanks for looking into this so quickly! It still seems to only change the color of the clips when the clip name is an exact match to what is in the name-color list. I'm trying to use this with scene markers to color code all Interior scenes one color and all Exterior scenes a different color. Scene clip name examples would be "Int House Night", "Int Kitchen Day", "Int Diner" - where I want to color all clips that contain "Int" the same color. Many thanks!
samuel henriques @samuel_henriques
-- UPDATED ABOVE --
You are correct, on my test it was working, but I was wrong.
I'm avoidingstartsWith
because I'm guessing you'll want to tweak this to be more useful with more locations, so with a little tweak its easy to change.
As it is working now, it will split the name at the " " (space) so "Int House Night" will become an array["Int", "House", "Night"]
and is taking the first in the array[0]
and looking in your color list.
in this line:const nameInColorName = Object.keys(colorName).filter(color => color.toLowerCase().indexOf(name.split(" ")[0].toLowerCase()) > -1)[0];
if you change the first ( not the last one)
[0]
to[1]
it will look for the second word of the name, in this example "House".Let me know if this makes sense, and if it's working for you.
Trip Brock @Trip_Brock
Wow thank you for the quick response- and yes this is now working greast. Thank you for the explanation
as well, this is super helpful! Cheers!