No internet connection
  1. Home
  2. How to

Rename clips by markers in Pro Tools

By Maggy Ayala @Maggy_Ayala
    2021-09-22 10:33:53.988Z2021-09-22 19:30:46.842Z

    Hello, I wonder if there is a way to make a script for Pro tools to rename all clips in a track (Beginnig to end of the session) by each marker in front of each clip
    I am trying to repeat this several times
    I found some script here but I think is incomplete for what I need
    Also, I would like to run this for clips that are already cut, avoiding a last strip silence again

    function getMemLocName() {
        const currentLocation = sf.ui.proTools.selectionGetInSamples()
        const memLocName = sf.proTools.memoryLocationsFetch().collection['list'].filter(x =>
            x.mainCounterValue >= currentLocation.selectionStart &&
            x.mainCounterValue <= currentLocation.selectionEnd
        )[0]
        return memLocName
    }
    
    
    function renameClip() {
    
        // Get First Memory Location Name from selection
        const memLocName = getMemLocName()
    
        if (memLocName != undefined) {
    
            //Open Rename window
            sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
    
            //Reference for Rename Window
            const renameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({ waitType: "Appear" }).element
    
            const nameClipOnlyButton = renameWin.groups.first.radioButtons.first
    
            ///  Set Clip Name Only
            if (nameClipOnlyButton.exists)
                renameWin.groups.first.radioButtons.first.checkboxSet({ targetValue: "Enable" });
    
            //  Set the clip name to Track name
            renameWin.groups.first.textFields.first.elementSetTextFieldWithAreaValue({ value: memLocName.Name });
    
            // Click OK
            renameWin.buttons.whoseTitle.is('OK').first.elementClick()
            //  Wait for window to cloce
            renameWin.elementWaitFor({ waitType: "Disappear" })
        }
    }
    
    
    function main() {
    
        //  Acivate Pro Tools
        sf.ui.proTools.appActivateMainWindow()
        //  Do For Each 
        sf.ui.proTools.clipDoForEachSelectedClip({
            action: renameClip,
            onError: "Continue"
        })
    }
    
    main()
    
    • 30 replies

    There are 30 replies. Estimated reading time: 31 minutes

    1. samuel henriques @samuel_henriques
        2021-09-23 10:55:45.270Z2021-09-23 11:18:32.884Z

        Hello Maggy,

        I think this was my code, and has a fundamental mistake, maybe it worked when I made it, but I can see now how it could fail.

        Here's the fixed code, and made it faster.

        Let me know how it goes.

        
        function getMemLoc() {
        
            // Functions to grab start and end time on any counter
            //( because its runnign on clipDoForEachSelectedClip it should be Samples, but will work on any)
            const getSelectionStart = () => sf.ui.proTools.selectionGet().selectionStart.replace(/[:.+| ]/g, '');
            const getSelectionEnd = () => sf.ui.proTools.selectionGet().selectionEnd.replace(/[:.+| ]/g, '');
        
            // filter mem locs within selection
            const memLocFromSelection = sf.proTools.memoryLocationsFetch().collection['list'].filter(m =>
                m.mainCounterValue.replace(/[:.+| ]/g, '') >= getSelectionStart() &&
                m.mainCounterValue.replace(/[:.+| ]/g, '') <= getSelectionEnd()
            );
        
            // return first memory location within selection
            return memLocFromSelection[0]
        };
        
        
        function renameClip() {
        
            // Get First Memory Location Name from selection
            const memLocFromSelection = getMemLoc()
        
            if (memLocFromSelection) {
        
                //Open Rename window
                sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
        
                //Reference for Rename Window
                const renameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({ waitType: "Appear" }).element
        
                const nameClipOnlyButton = renameWin.groups.first.radioButtons.first
        
                ///  Set Clip Name Only
                if (nameClipOnlyButton.exists)
                    renameWin.groups.first.radioButtons.first.checkboxSet({ targetValue: "Enable" });
        
                //  Set the clip name to Track name
                renameWin.groups.first.textFields.first.elementSetTextFieldWithAreaValue({ value: memLocFromSelection.name });
        
                // Click OK
                renameWin.buttons.whoseTitle.is('OK').first.elementClick()
                //  Wait for window to cloce
                renameWin.elementWaitFor({ waitType: "Disappear" })
            }
        }
        
        
        function main() {
        
            //  Acivate Pro Tools
            sf.ui.proTools.appActivateMainWindow()
            //  Do For Each 
            sf.ui.proTools.clipDoForEachSelectedClip({
                action: renameClip,
                onError: "Continue"
            })
        }
        
        main()
        
        
        
        
        1. M
          In reply toMaggy_Ayala:
          Maggy Ayala @Maggy_Ayala
            2021-09-23 11:51:24.346Z

            Hey Samuel, thanks a lot for your help

            Looks like a bit faster and it allows me to use it with clips I have already cut
            but the names what it start to put are ramdom
            ie
            clip 1 have a marker with 101 but the script ended naming like 123 (what is another marker in another place)

            1. samuel henriques @samuel_henriques
                2021-09-23 12:15:28.139Z

                umm...

                could you share a screen recording of it running?

                1. samuel henriques @samuel_henriques
                    2021-09-23 12:46:20.192Z

                    Could it be two clips that are actually the the same whole clip? It renames the first, and it changes when the script renames the second clip.

                    If you can have this situation, we could consolidate the clips before renaming them

                2. M
                  In reply toMaggy_Ayala:
                  Maggy Ayala @Maggy_Ayala
                    2021-09-23 16:57:13.231Z

                    Sure
                    Have a look here https://filebin.net/6scqrnqeeugvtp1h
                    I did try to consolidate each clip before run the script and the result is exactly the same

                    Oh man, I feel this is super close but .. haha

                    1. samuel henriques @samuel_henriques
                        2021-09-23 18:49:31.032Z

                        Got it, the script is looking for a marker within the clip selection, the first memory location after the start of the clip, but before its end. But, if there is no marker it shouldn't change the name.

                        Could you try to make the markers on the clips, just to see if it works better?

                        1. samuel henriques @samuel_henriques
                            2021-09-23 19:00:48.727Z

                            could you confirm the version of PT you are using?

                            and to work the way you want, where the markers are outside the clips, I need to think of another way.
                            Could be making a selection including the markers, and if the number of markers is the same as the number of selected clips, it would name each clip on the same order of markers. Does this make sense?

                            1. samuel henriques @samuel_henriques
                                2021-09-23 19:41:38.605Z2023-07-23 16:02:00.842Z

                                I made a new version based on your workflow. It will name the clips based on the memory locations in the selection and in the same order.

                                for example, the selection you made wouldn't,

                                In this case, the clip 1 would be named L09, clip 2 L11, clip 3 L13 and clip 4 wouldn't be named.

                                You must make a selection including the markers and the clips you want to rename.
                                First marker name will go to the first selected clip, second marker to the second clip and so on.
                                You can't have any other markers in the way otherwise it will use those to name.

                                Give this a try,

                                
                                function getMemLoc() {
                                
                                    // Functions to grab start and end time on any counter
                                    //( because its running on clipDoForEachSelectedClip it should be Samples, but will work on any)
                                    const getSelectionStart = () => sf.ui.proTools.selectionGet().selectionStart.replace(/[:.+| ]/g, '');
                                    const getSelectionEnd = () => sf.ui.proTools.selectionGet().selectionEnd.replace(/[:.+| ]/g, '');
                                
                                    // filter mem locs within selection
                                    const memLocFromSelection = sf.proTools.memoryLocationsFetch().collection['list'].filter(m =>
                                        m.mainCounterValue.replace(/[:.+| ]/g, '') >= getSelectionStart() &&
                                        m.mainCounterValue.replace(/[:.+| ]/g, '') <= getSelectionEnd()
                                    );
                                
                                    // return first memory location within selection
                                    return memLocFromSelection
                                }
                                
                                
                                
                                let index = 0
                                /**
                                * @param {array} memLocs
                                */
                                function renameClip(memLocs) {
                                
                                    if (memLocs[index]) {
                                
                                        //Open Rename window
                                        sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
                                
                                        //Reference for Rename Window
                                        const renameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({ waitType: "Appear" }).element
                                
                                        const nameClipOnlyButton = renameWin.groups.first.radioButtons.first
                                
                                        ///  Set Clip Name Only
                                        if (nameClipOnlyButton.exists)
                                            renameWin.groups.first.radioButtons.first.checkboxSet({ targetValue: "Enable" });
                                
                                        //  Set the clip name to Track name
                                        renameWin.groups.first.textFields.first.elementSetTextFieldWithAreaValue({ value: memLocs[index].name });
                                
                                        // Click OK
                                        renameWin.buttons.whoseTitle.is('OK').first.elementClick()
                                        //  Wait for window to cloce
                                        renameWin.elementWaitFor({ waitType: "Disappear" })
                                
                                        index++
                                    }
                                }
                                
                                
                                function main() {
                                
                                    //  Acivate Pro Tools
                                    sf.ui.proTools.appActivateMainWindow();
                                    sf.ui.proTools.invalidate();
                                
                                    sf.ui.proTools.memoryLocationsEnsureWindow({
                                        restoreWindowOpenState: true,
                                        action: () => {
                                
                                            // Get Locations from selection
                                            const memLocFromSelection = getMemLoc()
                                
                                            //  Do For Each 
                                            sf.ui.proTools.clipDoForEachSelectedClip({
                                                action: () => renameClip(memLocFromSelection),
                                                onError: "Continue"
                                            });
                                        }
                                    });
                                };
                                
                                
                                main();
                                
                                1. VVasiko Tsabadze @Vasiko_Tsabadze
                                    2023-06-23 06:42:30.326Z

                                    Hey Samuel !

                                    Following a recent update of Pro Tools, it seems that the script is no longer functioning as intended. As someone who heavily relies on this functionality for my workflow, I was wondering if you have time to updating the script to make it compatible with the latest version of Pro Tools 2023.6.

                                    Thanks !

                                    1. samuel henriques @samuel_henriques
                                        2023-06-23 08:14:41.199Z

                                        Hello Vasiko,
                                        Just tested and it's working on my 2023.6. Are you getting any error?
                                        You can make a screen capture video of the script failing so I can try to figure what is working differently

                                        1. samuel henriques @samuel_henriques
                                            2023-06-23 08:29:23.544Z

                                            The new marker window is different but the way the script is reading the marker list is still the same.
                                            Can you double check the sort by option is Time?

                                            1. VVasiko Tsabadze @Vasiko_Tsabadze
                                                2023-06-26 13:31:37.643Z

                                                Yes, markers are sorted by Time.
                                                Here is the video: https://youtu.be/aSeUCH9LyGQ

                                                1. samuel henriques @samuel_henriques
                                                    2023-06-26 13:47:20.154Z

                                                    Can't reproduce the issue.
                                                    I made a slight change and updated above, could you try the new version please?

                                                    1. Ssgiacometti @sgiacometti
                                                        2023-10-24 15:41:53.770Z

                                                        Hey Samuel, should this script still work with PT 2023.9?

                                                        It's not working for me at the moment (it goes through all clips, but doesn't change the name).
                                                        I'm pretty new at this, but after trying to figure out what's going on, it looks like memLocFromSelection is filtering memory locations by Main Counter Value, so it's expecting a value in samples. With the current version of PT, I get this as memoryLocationsFetch result:

                                                        "Number": 3,
                                                        "Name": "3",
                                                        "MarkerTrack": "Selected. Marker Ruler",
                                                        "MainCounterValue": "Marker Ruler'

                                                        This of course means that no markers are found after filtering, so the name stays unchanged.

                                                        Am I doing something wrong, or is memoryLocationsFetch currently not working as it should?

                                                        1. samuel henriques @samuel_henriques
                                                            2024-02-20 12:31:07.649Z

                                                            hello sgiacometti,

                                                            pro tools has changed the memory location window.
                                                            replace lines 1 to 19 with,

                                                            /**
                                                             * Retrieves a list of memory locations.
                                                             *
                                                             * @function
                                                             * @returns {Array<Object>} An array of objects representing memory locations.
                                                             * @property {boolean} isSelected - Indicates whether the memory location is selected.
                                                             * @property {string} Sharing Merging
                                                             * @property {string} Active Location
                                                             * @property {string} Number
                                                             * @property {string} Name
                                                             * @property {string} Track Name
                                                             * @property {string} Marker View filter
                                                             * @property {string} Selection Memory Location View filter
                                                             * @property {string} Zoom Settings View filter
                                                             * @property {string} Pre/Post-Roll View filter
                                                             * @property {string} Show/Hide View filter
                                                             * @property {string} Track Heights View filter
                                                             * @property {string} Active Groups View filter
                                                             * @property {string} Window Configuration filter
                                                             * @property {string} Venue Snapshot filter
                                                             * @property {string} MainCounterValue
                                                             * @property {string} Sub Counter
                                                             * @property {string} Comments
                                                             */
                                                            function getMemoryLocationsList() {
                                                                let memLocList = []
                                                                sf.ui.proTools.memoryLocationsEnsureWindow({
                                                                    action: () => {
                                                                        const memLocWin = sf.ui.proTools.memoryLocationsWindow.tables.whoseTitle.is("Memory Locations")
                                                                        const memLocColumns = memLocWin.first.children.whoseRole.is("AXColumn").first.children.whoseRole.is("AXRow").first.children.whoseRole.is("AXCell").map(mem =>
                                                                            mem.children.whoseRole.is("AXStaticText").first.title.value
                                                                                .replace("Numeration", "number")
                                                                                .replace("Marker Name", "name")
                                                                                .replace("Main Counter", "mainCounterValue")
                                                                        );
                                                            
                                                                        memLocWin.allItems[1].children.whoseRole.is("AXRow").map(r => {
                                                                            let obj = {};
                                                                            r.children.whoseRole.is("AXCell").map((cell, i) => {
                                                            
                                                                                obj["isSelected"] = false
                                                                                const cellValue = cell.children.whoseRole.is("AXStaticText").first.value.value
                                                            
                                                                                if (cellValue.startsWith("Selected. ")) {
                                                                                    obj["isSelected"] = true
                                                                                }
                                                            
                                                                                obj[memLocColumns[i]] = cellValue.replace("Selected. ", "")
                                                                            })
                                                                            memLocList.push(obj)
                                                                        })
                                                            
                                                                    },
                                                                    restoreWindowOpenState: true
                                                                })
                                                                return memLocList
                                                            };
                                                            
                                                            
                                                            
                                                            function getMemLoc() {
                                                            
                                                                // Functions to grab start and end time on any counter
                                                                //( because its runnign on clipDoForEachSelectedClip it should be Samples, but will work on any)
                                                                const getSelectionStart = () => +sf.ui.proTools.selectionGet().selectionStart.replace(/[:.+| ]/g, '');
                                                             
                                                                const getSelectionEnd = () => +sf.ui.proTools.selectionGet().selectionEnd.replace(/[:.+| ]/g, '');
                                                               
                                                                // filter mem locs within selection
                                                                const memLocFromSelection = getMemoryLocationsList().filter(m =>
                                                                    +m.mainCounterValue.replace(/[:.+| ]/g, '') >= getSelectionStart() &&
                                                                    +m.mainCounterValue.replace(/[:.+| ]/g, '') <= getSelectionEnd()
                                                                );
                                                            
                                                                // return first memory location within selection
                                                                return memLocFromSelection
                                                            }
                                                            
                                                2. Hi, I want to do something very similar, except that instead of replacing the clip name, I want to add each marker name to the beginning of each clip's current name, I would imagine using Batch Rename instead of Rename. And then ideally, I'd like to do that for all selected clips on all tracks

                                                  1. samuel henriques @samuel_henriques
                                                      2023-07-23 12:21:58.647Z

                                                      Hello Kurt,
                                                      This script will go to each selected clip and read the marker within the clip selection. Bach rename clips, wouldn't know what marker is within each clip. So we would have to go clip by clip and rename it one at a time.
                                                      Unless you have one marker for all the selected clips, so one name you want to add on all selected clips, that would be, append to clip name in the batch rename.

                                                      Let me know witch one you need.

                                                      1. Hi Samuel, and TIA!
                                                        Basically, all I want is exactly the same behavior as the current script, but to add each marker name as a prefix to the current clip name instead of replacing the current clip name, so the resulting clip name would be something like "(MarkerName)_(ClipCurrentName)". I only mentioned Batch Rename because it has an "Add: Prefix" field I thought might be useful for this.

                                                        1. So in this example, the resulting name of the first few clips would be "Location 1_Audio 1_02", "Location 2_Audio 1_01-05", etc.

                                                          1. samuel henriques @samuel_henriques
                                                              2023-07-23 16:00:02.083Z

                                                              Sure, replace the renameClip function from lines 22 to 51 with:

                                                              /**
                                                              * @param {array} memLocs
                                                              */
                                                              function renameClip(memLocs) {
                                                              
                                                                  if (memLocs[index]) {
                                                              
                                                                      //Open Rename window
                                                                      sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
                                                              
                                                                      //Reference for Rename Window
                                                                      const renameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({ waitType: "Appear" }).element
                                                              
                                                                      const nameClipOnlyButton = renameWin.groups.first.radioButtons.first
                                                              
                                                                      ///  Set Clip Name Only
                                                                      if (nameClipOnlyButton.exists)
                                                                          renameWin.groups.first.radioButtons.first.checkboxSet({ targetValue: "Enable" });
                                                              
                                                                      const currentClipName = renameWin.groups.first.textFields.first.value.invalidate().value
                                                                      const newClipName = memLocs[index].name + "_" + currentClipName
                                                              
                                                                      //  Set the clip name to Track name
                                                                      renameWin.groups.first.textFields.first.elementSetTextFieldWithAreaValue({ value: newClipName });
                                                              
                                                                      // Click OK
                                                                      renameWin.buttons.whoseTitle.is('OK').first.elementClick()
                                                                      //  Wait for window to cloce
                                                                      renameWin.elementWaitFor({ waitType: "Disappear" })
                                                              
                                                                      index++
                                                                  }
                                                              }
                                                              
                                                              1. Excellent! Thanks!! One last thing, would there be a way to skip renaming clips that have no marker within their boundaries? Or put another way: only rename clips that have markers within their start and end points?

                                                                1. samuel henriques @samuel_henriques
                                                                    2023-07-23 17:53:25.471Z

                                                                    ok, now the old script would grab the collection of markers in the initial selection and add info on them to the clips in the same selection, the markers did't have to be within the clip boundary, so the first maker info would go to the first clip in the selection the second marker to second clip and so on. This has a problem where selected clips in the selection could be in a different order than the same clips on the clip list and pro tools uses the clip list order to rena clips, using the old script method.

                                                                    this new one will select the first clip in the selection, then check what markers exist within the selected clip boundary and add it's name to the clip name the way you asked. If more than one marker exist, it will use the first, if no marker exists it will skip the clip.

                                                                    I hope I was clear, just so you use them accordingly depending on the case.

                                                                    Here yo go:

                                                                    function getMemLoc() {
                                                                    
                                                                        // Functions to grab start and end time on any counter
                                                                        //( because its running on clipDoForEachSelectedClip it should be Samples, but will work on any)
                                                                        const getSelectionStart = () => sf.ui.proTools.selectionGet().selectionStart.replace(/[:.+| ]/g, '');
                                                                        const getSelectionEnd = () => sf.ui.proTools.selectionGet().selectionEnd.replace(/[:.+| ]/g, '');
                                                                    
                                                                        // filter mem locs within selection
                                                                        const memLocFromSelection = sf.proTools.memoryLocationsFetch().collection['list'].filter(m =>
                                                                            m.mainCounterValue.replace(/[:.+| ]/g, '') >= getSelectionStart() &&
                                                                            m.mainCounterValue.replace(/[:.+| ]/g, '') <= getSelectionEnd()
                                                                        );
                                                                    
                                                                        // memory locations within selection
                                                                        return memLocFromSelection
                                                                    }
                                                                    
                                                                    
                                                                    
                                                                    function renameClip() {
                                                                    
                                                                        const memLocFromSelection = getMemLoc();
                                                                    
                                                                        // If mem loc exists
                                                                        if (memLocFromSelection.length) {
                                                                    
                                                                            //Open Rename window
                                                                            sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
                                                                    
                                                                            //Reference for Rename Window
                                                                            const renameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({ waitType: "Appear" }).element
                                                                    
                                                                            ///  Set Clip Name Only
                                                                            const nameClipOnlyButton = renameWin.groups.first.radioButtons.first
                                                                            if (nameClipOnlyButton.exists)
                                                                                renameWin.groups.first.radioButtons.first.checkboxSet({ targetValue: "Enable" });
                                                                    
                                                                            //Get current clip name
                                                                            const currentClipName = renameWin.groups.first.textFields.first.value.invalidate().value;
                                                                    
                                                                            //Build new name
                                                                            const newClipName = memLocFromSelection[0].name + "_" + currentClipName;
                                                                    
                                                                            //  Set the clip name to Track name
                                                                            renameWin.groups.first.textFields.first.elementSetTextFieldWithAreaValue({ value: newClipName });
                                                                    
                                                                            // Click OK
                                                                            renameWin.buttons.whoseTitle.is('OK').first.elementClick()
                                                                            //  Wait for window to cloce
                                                                            renameWin.elementWaitFor({ waitType: "Disappear" })
                                                                        };
                                                                    
                                                                    };
                                                                    
                                                                    
                                                                    
                                                                    function main() {
                                                                    
                                                                        //  Acivate Pro Tools
                                                                        sf.ui.proTools.appActivateMainWindow();
                                                                        sf.ui.proTools.invalidate();
                                                                    
                                                                        sf.ui.proTools.memoryLocationsEnsureWindow({
                                                                            restoreWindowOpenState: true,
                                                                            action: () => {
                                                                    
                                                                                //  Do For Each 
                                                                                sf.ui.proTools.clipDoForEachSelectedClip({
                                                                                    action: () => renameClip(),
                                                                                    onError: "Continue"
                                                                                });
                                                                            }
                                                                        });
                                                                    };
                                                                    
                                                                    
                                                                    main();
                                                                    
                                                                    
                                                                    
                                                                    1. Very nice, I think this does it! For some reason, in my test session it is skipping marker-to-clip name "Location 1", but that might be something to do with the clip creation. But yes, this looks like it gets at least 99% of the way there. Thank you!!

                                                3. M
                                                  In reply toMaggy_Ayala:
                                                  Maggy Ayala @Maggy_Ayala
                                                    2021-09-24 12:20:34.488Z

                                                    Hey Samuel, this one definetly works a lot better, pretty happy about it :) again, thanks so much for you help
                                                    Still, I can see even I made sure each clip is near to his marker, at some point just stop to rename (but still does the process like copying the name from the marker, and still at some point takes from the marker 2 clips away
                                                    I also notice that It doesnt name correctly if I do a huge selection

                                                    I am still trying to figure all the little glitches
                                                    I will so another little video soon

                                                    1. M
                                                      In reply toMaggy_Ayala:
                                                      Maggy Ayala @Maggy_Ayala
                                                        2021-09-24 12:41:30.087Z

                                                        Have a look

                                                        https://filebin.net/vxw9vrnb5e448q8e

                                                        there are bit even I am inside the rules I was following for the others clips, (as you said for the new script, select markers and clips to rename) still, it will not rename correctly, even if I consolidate again
                                                        I am on PT 2020.12.0 and OSX 10.15.6

                                                        1. samuel henriques @samuel_henriques
                                                            2021-09-24 16:05:17.756Z2021-09-24 16:40:11.479Z

                                                            something else is wrong, it should choose "name clip only" and its not doing it, on the other video as well. The recording might be missing if because it's too fast, but you should be able to see it.

                                                            can't say if it has to do with versions of pt, but I'm on 2021.7, and might be some things different versions do to soundFlow.

                                                            on this video, it didn't rename anything, or you made the video after renaming?

                                                            do you see the memory locations window open and close?

                                                            1. samuel henriques @samuel_henriques
                                                                2021-09-24 16:17:24.363Z2023-06-26 13:45:38.449Z

                                                                you have the memory locations sorted by number, could you try to sort by time?
                                                                it certainly makes a difference for this workflow.

                                                            2. W
                                                              In reply toMaggy_Ayala:
                                                              William Kleinsasser @William_Kleinsasser
                                                                2023-10-09 15:46:33.630Z2023-10-12 00:40:25.917Z

                                                                Hello, I have a need to use this exact functionality in Protools sessions with multiple clips. I'm using Protools version 2022.9.0 for reasons of plugin compatibility. The script below is not working for me. I'm selecting all the clips in the session, including the markers bar and then running the script but in Protools the only thing that happens is Protools becomes the active top application. If anyone can help, I'd really appreciate it.

                                                                Thanks,
                                                                WK

                                                                function getMemLoc() {
                                                                
                                                                    // Functions to grab start and end time on any counter
                                                                    //( because its runnign on clipDoForEachSelectedClip it should be Samples, but will work on any)
                                                                    const getSelectionStart = () => sf.ui.proTools.selectionGet().selectionStart.replace(/[:.+| ]/g, '');
                                                                    const getSelectionEnd = () => sf.ui.proTools.selectionGet().selectionEnd.replace(/[:.+| ]/g, '');
                                                                
                                                                    // filter mem locs within selection
                                                                    const memLocFromSelection = sf.proTools.memoryLocationsFetch().collection['list'].filter(m =>
                                                                        m.mainCounterValue.replace(/[:.+| ]/g, '') >= getSelectionStart() &&
                                                                        m.mainCounterValue.replace(/[:.+| ]/g, '') <= getSelectionEnd()
                                                                    );
                                                                
                                                                    // return first memory location within selection
                                                                    return memLocFromSelection[0]
                                                                };
                                                                
                                                                
                                                                function renameClip() {
                                                                
                                                                    // Get First Memory Location Name from selection
                                                                    const memLocFromSelection = getMemLoc()
                                                                
                                                                    if (memLocFromSelection) {
                                                                
                                                                        //Open Rename window
                                                                        sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
                                                                
                                                                        //Reference for Rename Window
                                                                        const renameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({ waitType: "Appear" }).element
                                                                
                                                                        const nameClipOnlyButton = renameWin.groups.first.radioButtons.first
                                                                
                                                                        ///  Set Clip Name Only
                                                                        if (nameClipOnlyButton.exists)
                                                                            renameWin.groups.first.radioButtons.first.checkboxSet({ targetValue: "Enable" });
                                                                
                                                                        //  Set the clip name to Track name
                                                                        renameWin.groups.first.textFields.first.elementSetTextFieldWithAreaValue({ value: memLocFromSelection.name });
                                                                
                                                                        // Click OK
                                                                        renameWin.buttons.whoseTitle.is('OK').first.elementClick()
                                                                        //  Wait for window to cloce
                                                                        renameWin.elementWaitFor({ waitType: "Disappear" })
                                                                    }
                                                                }
                                                                
                                                                
                                                                function main() {
                                                                
                                                                    //  Acivate Pro Tools
                                                                    sf.ui.proTools.appActivateMainWindow()
                                                                    //  Do For Each 
                                                                    sf.ui.proTools.clipDoForEachSelectedClip({
                                                                        action: renameClip,
                                                                        onError: "Continue"
                                                                    })
                                                                }
                                                                
                                                                main()
                                                                
                                                                
                                                                1. WWilliam Kleinsasser @William_Kleinsasser
                                                                    2023-10-12 00:39:31.512Z2023-10-19 14:09:18.930Z

                                                                    I figured it out. In the Protools session only one track can be selected. Before running the script, open Protools file and select a single track name in the left column of the tracks window, then select the region and include the marker strip in the selection. Be sure that markers and clips are sorted by time not name. With these settings and selection, run the SoundFlow script to rename clips with marker names. This is such a useful script! Thank you.

                                                                  • D
                                                                    In reply toMaggy_Ayala:
                                                                    Dylan Furrow @Dylan_Furrow
                                                                      2024-08-30 17:06:43.062Z

                                                                      Hey guys, I've been trying to use this script and it doesn't seem to be renaming the clips. Everything else seems fine though