No internet connection
  1. Home
  2. How to

Color Code clips based on Channel Name

By Mike Wax @mikewax
    2022-12-03 01:32:06.304Z

    Hello SF Group!

    I am in desperate need of help on this script. I tried 3 days of research and got no where. My apologies ahead of time for the lengthy description, but I wanted to be as detailed as possible.

    Usually I will get AAF files from an editor, and the clips are scattered all over the place. Boom will jump from Ch. 1 to Ch. 6, Lav clips will be on 4 different tracks, etc. So I decided to write a script that would go through my AAF folder and color code these clips for me. That way, I have a nice visual of where my clips are, and save a lot of time organizing them to the proper tracks.

    Now, not all my sessions will have the same Channel Names. I was able to make a simple one saying "if the Channel Name is BOOM, color it RED. If the Channel Name is LAV, color it Blue. But I want it be a little more universal. Not all my sessions will have only LAV and BOOM. Some will have MOM, or KID, or PlantBoom/CarBoom, MixL, etc.

    So to try and solve this, I thought it would be best to create a prompt that allows you to enter what Channel Names you're looking for. That prompt stores the responses into an Array.

    Here's where I run into problems. I am trying to color each channel name differently based on the array index. This way it doesn't have to be in order, and I'm ok not having the same channels the same colors all the time, since I won't always have the same channels in some projects.

    So I'm trying to say "if there's a value in index slot 0, color it. index slot 0 says 'Boom', so find all the Channel Names that match and color 'Boom' channels color 1. If there's a value in index slot 1, color it. index slot 1 says 'Ben', so find all the Channel Names that match and color 'Ben' channels color 5." etc.

    If it finds a channel name that was not listed in the array, it leaves that clip the default color.

    I did a quick mockup of what I'm trying to do. You can see in the screenshot how Channels named "Ben" are colored BLUE. Channels named BOOM are green. Channels named MixL and MixR are left default since I did not enter them into the array.

    I'm happy to clarify further if needed, and am completely open to any new ideas on how to achieve this. Thank you so much for the help, and my apologies for the long, confusing post.

    The result I'm currently getting is that it colors all the clips the same color, even if it's not listed in the array/

    Here is the current code:

    sf.ui.proTools.appActivate();
    
    const channelNamesPrompt = prompt("What Channel Names are you looking for?\nSeparate items using a comma (,).");
    const arraySlice = channelNamesPrompt.split(", ");
    
    
    const aafFolderName = "— AAF —"
    
    sf.ui.proTools.trackSelectByName({
        names: [aafFolderName]
    });
    
    sf.keyboard.press({
        keys: "alt+a"
    });
    
    // Get children tracks in folder.
    function selectFolderChildren() {
        sf.ui.proTools.menuClick({ menuPath: ["Edit", "Selection", "Extend Edit Down"] })
        sf.ui.proTools.menuClick({ menuPath: ["Edit", "Selection", "Remove Edit from Top"] })
        sf.ui.proTools.menuClick({ menuPath: ["Edit", "Selection", "Extend Edit Down to Members"] });
    
        sf.ui.proTools.menuClick({
            menuPath: ["Edit", "Select All"]
        });
    }
    
    selectFolderChildren();
    
    //Do for each track.
    const folderTracks = sf.ui.proTools.selectedTracks.trackHeaders.slice().map(track => {
        track.trackSelect();
        track.trackScrollToView();
    
        function colorClip() {
    
            sf.ui.proTools.menuClick({
                menuPath: ["Clip", "Rename..."]
            });
    
            const renameWin = sf.ui.proTools.windows.whoseTitle.is("Name").first;
            const clipChannelName = renameWin.groups.whoseTitle.is("Clip Info").first.children.whoseRole.is("AXStaticText").allItems[8].value.invalidate().value;
    
            renameWin.buttons.whoseTitle.is("Cancel").first.elementClick();
    
            let c = 0;
    
            for (let i = 0; i < arraySlice.length; i++) {
                sf.ui.proTools.colorsSelect({
                    colorTarget: "ClipsInTracks",
                    colorNumber: c+=3
                });
            }
    
        };
    
        sf.ui.proTools.clipDoForEachSelectedClip({
            action: colorClip
        });
    });
    
    Solved in post #60, click to view
    • 69 replies

    There are 69 replies. Estimated reading time: 37 minutes

    1. O
      Oscar Vargas @Oscar_Vargas
        2023-05-16 19:26:09.755Z

        This would be very useful. And to take it a step further , it would be great to be able to delete / copy / cut any clips with a specific Channel Name.

        1. Mike Wax @mikewax
            2023-05-17 03:06:34.775Z

            Hey @Oscar_Vargas ,

            Thanks for the reply!

            I a=was actually able to complete this script in a different way, much to what you mentioned. I thought "why don't i just put the clips on the proper tracks, that saves me a step". So i did that instead.

            This script will find all the tracks in a folder (AAF folder) then create a new DX folder, get all the clip names, make new tracks based on the clips names, then match the clip to the proper track.

            It's been such a time saver, especially on longer productions.

            I have a package on the store that includes this template, along with a few others if needed. Just search for AAF Helpers. I plan on updating it soon as well.
            Hope this helps you out!

            1. OOscar Vargas @Oscar_Vargas
                2023-05-17 06:24:44.842Z

                Thanks Mike! I tried to look for it on the store and I couldn't find that specific one.

                1. Mike Wax @mikewax
                    2023-05-17 15:39:19.883Z
                    1. OOscar Vargas @Oscar_Vargas
                        2023-05-18 17:38:31.091Z

                        Sorry, this is pretty annoying. But the link just tells me how to search for it in the SF store. And when I type exactly "AAF Helpers" on the SF Store search nothings comes up.
                        If I type just "AAF" there´s only result:

                        1. Mike Wax @mikewax
                            2023-05-18 17:41:01.956Z

                            That's so strange...sorry for the hassle.

                            click to show
                  • O
                    In reply tomikewax:
                    Oscar Vargas @Oscar_Vargas
                      2023-05-18 18:49:26.758Z

                      Hey @mikewax , I've tried your script but not sure of what I'm doing wrong I get the following message:

                      Default Preset failed:
                      TypeError: Cannot read property
                      'folderTrackSetOpen' of null

                      1. Mike Wax @mikewax
                          2023-05-18 18:50:54.425Z

                          Hey @Oscar_Vargas,

                          Which script are you getting that error on?

                          1. OOscar Vargas @Oscar_Vargas
                              2023-05-18 18:53:56.033Z

                              The "Default Preset" script

                              1. OOscar Vargas @Oscar_Vargas
                                  2023-05-18 19:00:40.571Z

                                  Does it matter if it's a Routing Folder or a normal Folder that contains all the AAF clips ? I've been testing it with Routing Folders

                                  1. Mike Wax @mikewax
                                      2023-05-18 19:02:37.079Z

                                      It should work with both basic and routing folders.

                                      click to show
                              2. E
                                In reply tomikewax:
                                Ewa Leszczyńska @Ewa_Leszczynska
                                  2024-07-08 22:33:37.135Z

                                  Hi, your script is exactly what I have been looking for for a very, very long time. Unfortunately, it does not work for me (tested on 2 Mac M1 computers with PT 2024).

                                  The problem is that the script does not create the DX folder. The .log file shows something like this:

                                  09.07.2024 00:20:02.33 [Backend]: Logging error in action (01) WaitForPopupMenuAction: Popup window was not found after waiting 2000 ms
                                  Logging error in action (01) OpenPopupMenuFromElementAction: Popup menu was not found

                                  09.07.2024 00:20:02.33 [Backend]: Logging unknown error in action (02) RunCommandAction: Organize AAF Files to New Tracks TEMPLATE: Line 64

                                  09.07.2024 00:20:02.33 [Backend]: !! Command Error: Default Preset [user:clybw6vqj0000d210km92untb
                                  #clcs0qr940001in108kidv2nr]:
                                  Popup menu was not found (Organize AAF Files to New Tracks TEMPLATE: Line 64)
                                  Popup window was not found after waiting 2000 ms"

                                  Can you help?

                                  1. Mike Wax @mikewax
                                      2024-07-09 03:00:04.195Z

                                      Hey @Ewa_Leszczynska,

                                      Thank you for reaching out!

                                      I have not updated this to work with the updated version of Pro Tools. There was an issue with the context menus that needs an update in the code when PT 2024 came out.

                                      Please give me some time and i will get this fixed and working for the newer version of Pro Tools.
                                      I'm in the middle of a few projects, but will do my best to update this ASAP.

                                      I will let you know when it's updated.
                                      Thank you!

                                      1. EEwa Leszczyńska @Ewa_Leszczynska
                                          2024-07-09 14:34:50.745Z

                                          Thank You so much!!!

                                          1. EEwa Leszczyńska @Ewa_Leszczynska
                                              2024-07-13 20:53:02.254Z2024-07-13 20:59:49.446Z

                                              I will just add that I get exactly the same result on PT in all 2023 versions :/
                                              Maybe it's a matter of some settings in PT or in the OS? I have edit keyboard focus active of course.

                                              1. Mike Wax @mikewax
                                                  2024-07-15 21:14:08.061Z

                                                  Hi @Ewa_Leszczynska,

                                                  click to show
                                          2. B
                                            In reply tomikewax:
                                            Ben Zenium @Ben_Zenium
                                              2024-08-23 07:28:38.894Z

                                              Hi Mike, Im getting an error on line 226 for this script.

                                              23.08.2024 08:26:41.29 [Backend]: Logging unknown error in action (02) RunCommandAction: Organize AAF Files to New Tracks TEMPLATE: Line 226

                                              23.08.2024 08:26:41.29 [Backend]: !! Command Error: Default Preset Duplicate [user:cm06d7bt50000j610tgpe3y7n:clcsj56b20006wd103m9epiee#cm06dwpsk0005j610u25yawq2]:
                                              Could not open popup menu (Organize AAF Files to New Tracks TEMPLATE: Line 226)
                                              Popup menu was not found
                                              Popup window was not found after waiting 2000 ms

                                              1. Mike Wax @mikewax
                                                  2024-08-23 14:35:49.074Z

                                                  Hey Ben,

                                                  What version of the AAF Helpers are you running?

                                                  1. BBen Zenium @Ben_Zenium
                                                      2024-08-25 13:24:37.361Z

                                                      Hi Mike, its version 2.0.0

                                                      1. In reply tomikewax:
                                                        BBen Zenium @Ben_Zenium
                                                          2024-08-25 14:05:07.970Z2024-08-28 07:55:02.708Z

                                                          Hi @mikewax , I got past line 226, but I'm now getting this error

                                                          Logging unknown error in action (02) RunCommandAction: Organize AAF Files to New Tracks TEMPLATE: Line 259
                                                          !! Command Error: Default Preset Duplicate [user:cm06d7bt50000j610tgpe3y7n:clcsj56b20006wd103m9epiee#cm06dwpsk0005j610u25yawq2]:
                                                          ClickButtonAction requires UIElement (Organize AAF Files to New Tracks TEMPLATE: Line 259)
                                                          Couldn't get item #0 as the array length was 0 - sf.ui.app('com.avid.ProTools').children.whoseRole.is('AXWindow').first.buttons.whoseTitle.is('Next').first (AxElementArrayIndexedItem)

                                                          1. Mike Wax @mikewax
                                                              2024-08-29 19:11:16.707Z

                                                              Thanks Ben,

                                                              I'll take a look and try to get a fix uploaded ASAP.

                                                              1. Mike Wax @mikewax
                                                                  2024-09-05 02:18:20.476Z

                                                                  Hey Ban,

                                                                  click to show
                                                          2. T
                                                            In reply tomikewax:
                                                            Timothy Preston @Timothy_Preston
                                                              2024-11-17 00:54:42.870Z

                                                              I just downloaded the script to try it out, keeps failing at line 41 saying it can't find the pop up menu. Is there something I'm missing or does this not work with the new update that allows the clip list to be detachable?

                                                              " [Backend]: Logging unknown error in action (02) RunCommandAction: Organize AAF Files to New Tracks TEMPLATE: Line 41
                                                              !! Command Error: Default Preset [user:cm3kvadbe00006d1068jjt6s7:clcsj56b20006wd103m9epiee#clcs0qr940001in108kidv2nr]:
                                                              Could not open popup menu (Organize AAF Files to New Tracks TEMPLATE: Line 41)
                                                              popupMenu.open.fromElement requires an element
                                                              Couldn't get item #0 as the array length was 0 - sf.ui.app('com.avid.ProTools')..popUpButtons.whoseTitle.is('Clip List').first (AxElementArrayIndexedItem)"

                                                              1. Mike Wax @mikewax
                                                                  2024-11-17 03:54:26.849Z

                                                                  Hey Timothy,

                                                                  You are correct. I have not released an update that works with the detachable Clip List (PT 2024.10).

                                                                  I will try to get a new version uploaded soon that will be compatible with that.

                                                                  For now, if you'd like to use the script, please leave the clip list where it typically is and you shouldn't have any problems.

                                                                  Thank you so much for calling that out!

                                                                • O
                                                                  In reply tomikewax:
                                                                  Oscar Vargas @Oscar_Vargas
                                                                    2024-12-19 21:26:37.617Z

                                                                    Hi Mike!
                                                                    After a while without giving this package another try I have unsuccesfully attempted many times without any luck.

                                                                    Any suggestions? This definitely would be a time saver

                                                                    1. Mike Wax @mikewax
                                                                        2024-12-20 19:40:38.050Z

                                                                        Hey Oscar,

                                                                        I will do my best to take a look at the code and see what's going on.
                                                                        What version of PT are you on?

                                                                        1. BBen Zenium @Ben_Zenium
                                                                            2025-01-08 17:30:18.214Z

                                                                            Hey Mike, can confirm it no longer works on the latest version of PT! Im dialling my version back but just thought I'd let you know!

                                                                            1. Mike Wax @mikewax
                                                                                2025-01-08 18:08:00.199Z

                                                                                Hey Ben,

                                                                                Thanks for the heads up. I need to update it to work with the new Clips List.
                                                                                It might be a bit before i can get to it, but i promise to make sure to get it updated as soon as i can.

                                                                                Thanks!

                                                                                1. BBen Zenium @Ben_Zenium
                                                                                    2025-01-08 23:07:28.153Z

                                                                                    Not a problem Mike, i dialled back just to use the version that works so no stress - thanks for the quick response!

                                                                                    click to show