No internet connection
  1. Home
  2. How to

How to copy Clip name, consolidate and paste the name on the new clip?

By Joachim Jorddal @Joachim_Jorddal
    2020-04-24 14:22:31.477Z2020-04-24 15:43:38.796Z

    I was wondering if there is a neat script or macro to achieve the following:

    Let's say I have a clip and I select a small region within the clip and de-click with RX. I now have 3 clips, but I want to have one single whole file so I consolidate them and Pro Tools renames the new clip to Stereo X or Mono X.
    I want to keep the name from the original clip after consolidating, so pre-SoundFlow I've done it like this:

    1. Select the clips
    2. Double-click on the selection
    3. Copy the name
    4. Hit enter to exit the Clip-name window
    5. Consolidate
    6. Double-click on the new consolidated clip
    7. Paste the copied name
    8. Hit enter to exit the Clip-name window again

    I would love to have that in a single button!
    I got this far by searching the forums and the included SoundFlow-scripts:

    sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
    
    sf.ui.proTools.menuClick({
      menuPath: ["Edit","Copy"],
    });
    

    But I can't find the command to close the Clip-name window after copying so it stops there.
    Please help a script-newbie out :)

    • 19 replies

    There are 19 replies. Estimated reading time: 15 minutes

    1. Kitch Membery @Kitch2020-04-25 08:24:09.845Z

      Hi Joachim,

      I have a script that is very close to this. If I get a chance tomorrow, I'll see if I can tailor it for your purpose.

      Rock on!

      1. In reply toJoachim_Jorddal:
        Kitch Membery @Kitch2020-04-25 09:39:49.746Z2020-04-30 01:05:11.723Z

        Here it is in action Joachim,

        I thought I'd make a screen capture of it so you can see whats happening. (Be sure to watch it in HD 1080p60)

        This script does the following;

        1. Consolidates the selected clip.
        2. Re-names the consolidated clip based on the first clips "Parent Name" Label in the Rename window.
        3. Adds an incremented version number (ie V2, V3... etc)
        4. Changes the color of the consolidated clip.

        Here is the Script;

        //Activate Protools
        sf.ui.proTools.appActivateMainWindow();
        
        function main() {
            //Clear Clip List Search
            sf.keyboard.press({
                keys: 'cmd+shift+d',
                fast: true
            });
        
            //Get Selection in Samples
            var oldSelection = sf.ui.proTools.selectionGetInSamples();
        
            //Press Down Key and Shift Tab to select first clip
            sf.keyboard.press({
                keys: "down, shift+quote",
            });
        
            //Check that first selection is a full clip and not a fade by checking to see if menu item "Loop..." is enabled
            //If the first selection is a fade, extend the region selection to the region end.
            if (!sf.ui.proTools.getMenuItem("Clip", "Loop...").isEnabled) {
                sf.keyboard.press({
                    keys: "shift+tab",
                });
            };
        
            //Open Clip => Rename
            sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
        
            //Wait for Rename window to Appear
            sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({
                waitType: "Appear",
            });
        
            sf.ui.proTools.windows.whoseTitle.is('Name').first.windowMove({
                size: { "x": 1000, "y": 451 },
            });
        
            //Get Parent File name
            var parentName = sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Clip Info').first.children.whoseRole.is("AXStaticText").allItems[2].value.value;
        
            sf.ui.proTools.windows.whoseTitle.is('Name').first.windowMove({
                size: { "x": 316, "y": 451 },
            });
        
            //Remove .wav from end of parent file name
            var parentNameWithoutWav = parentName.split('.').slice(0, -1).join('.');
        
            //Click Rename window Cancel button
            sf.ui.proTools.windows.whoseTitle.is('Name').first.buttons.whoseTitle.is('Cancel').first.elementClick();
        
            //Wait for Rename window to Disappear
            sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({
                waitType: "Disappear",
            });
        
            //Set old Selection
            sf.ui.proTools.selectionSetInSamples({
                selectionStart: oldSelection.selectionStart,
                selectionLength: oldSelection.selectionLength
            });
        
            //Consolidate Clips
            sf.ui.proTools.clipConsolidate();
        
            //Wait for Modals
            sf.ui.proTools.waitForNoModals();
        
            //Open Clip => Rename
            sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
        
            //Wait for Rename window to Appear
            sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({
                waitType: "Appear",
            });
        
            //Check that the clip info is visible, if not open it 
            if (!sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Clip Info').first.children.whoseRole.is("AXStaticText").whoseValue.is('User Time Stamp:').first.exists) {
                sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Clip Info').first.mouseClickElement({
                    relativePosition: { "x": 12, "y": 12 },
                });
            };
        
            //Get and Increment Last Number
            function getAndIncrementLastNumber(str) {
                return str.replace(/\d+$/, function (s) {
                    return ++s;
                });
            }
        
            //Variable for new clip name
            var newClipName = getAndIncrementLastNumber(parentNameWithoutWav);
        
            if (newClipName == parentNameWithoutWav) {
                //Set the name to parentNameWithoutWav_v2
                sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Name').first.textFields.first.elementSetTextFieldWithAreaValue({ value: parentNameWithoutWav + " v2" });
            }
            else {
                //Set the name of the new consolidated file
                sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Name').first.textFields.first.elementSetTextFieldWithAreaValue({ value: newClipName });
            };
        
            //Click Rename window OK button
            sf.ui.proTools.windows.whoseTitle.is('Name').first.buttons.whoseTitle.is('Ok').first.elementClick();
        
            //Wait for Rename window to Disappear
            sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({
                waitType: "Disappear",
            });
        
            //Change clip color to pink
            sf.ui.proTools.colorsSelect({
                colorTarget: "ClipsInTracks",
                colorNumber: 4,
            });
        }
        
        //Change the Main Counter to Samples for the duration of the main function
        sf.ui.proTools.mainCounterDoWithValue({
            targetValue: 'Samples',
            action: () => {
                main();
            }
        });
        

        Hope that helps :-)
        Rock on!

        1. JJoachim Jorddal @Joachim_Jorddal
            2020-04-25 14:21:01.131Z2020-04-25 17:43:54.152Z

            Hi Kitch,
            Thank you so much for your reply, exactly what I'm looking for! Nice touch with the change of colour and adding the increment.

            Just tried it out, but for some reason it doesn't keep the name, so my new consolidated file is simply named "v2". Any idea what's causing it?

            1. Kitch Membery @Kitch2020-04-25 19:14:27.160Z

              I’ll take another look at the script and see what’s going on. What version of Pro Tools and operating system are you running?

              1. JJoachim Jorddal @Joachim_Jorddal
                  2020-04-27 08:07:10.789Z

                  Pro Tools Ultimate 2019.12.0
                  MacOS Mojave 10.14.6

                  1. Kitch Membery @Kitch2020-04-27 08:15:41.388Z

                    Hi Joachim,

                    I took another look but can't work out why it is not working.

                    Could you try removing the following two sections of code, restart Pro Tools and try it again?

                        sf.ui.proTools.windows.whoseTitle.is('Name').first.windowMove({
                            size: { "x": 1000, "y": 451 },
                        });
                    

                    &

                        sf.ui.proTools.windows.whoseTitle.is('Name').first.windowMove({
                            size: { "x": 316, "y": 451 },
                        });
                    

                    Let me know how that goes.

                    1. JJoachim Jorddal @Joachim_Jorddal
                        2020-04-27 08:41:17.520Z

                        Still not working :(
                        Here is a screen capture:
                        https://www.dropbox.com/s/02g4v1c8htgxssq/ConsolidateScript.mov?dl=0

                        1. Kitch Membery @Kitch2020-04-27 08:53:56.852Z

                          Very helpful thanks...

                          It seems the Rename (Titled "Name") dialog is not opening. Or is it just the video frame rate, and I'm not seing it?

                          Try this;

                          1. Select any clip.
                          2. Select the "Clip" menu rename "Rename..." (or is it grey out?)
                          3. Does the "Name" window appear?
                          1. JJoachim Jorddal @Joachim_Jorddal
                              2020-04-27 09:00:52.204Z

                              Seems like I found the problem now! I didn't have Clip Info open in the Clip Rename window, but now that I've opened it it's working perfectly.

                              Again, thank you so much for the script and for the help! This will be a huge timesaver for me as I do a lot of sound library editing.

                              1. Kitch Membery @Kitch2020-04-27 09:10:20.494Z2020-04-27 09:44:49.544Z

                                Nice!!!

                                I was helping someone out with that exact issue the other day. I don't know why I didn't add it to the script.

                                Add the following code;

                                //Check that the clip info is visible, if not open it 
                                if (!sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Clip Info').first.children.whoseRole.is("AXStaticText").whoseValue.is('User Time Stamp:').first.exists) {
                                    sf.ui.proTools.windows.whoseTitle.is('Name').first.groups.whoseTitle.is('Clip Info').first.mouseClickElement({
                                        relativePosition: { "x": 12, "y": 12 },
                                    });
                                };
                                

                                ...after this code;

                                    //Wait for Rename window to Appear
                                    sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({
                                        waitType: "Appear",
                                    });
                                

                                Be sure to re-add the things I told you to take out. They are in place for a reason. They change the size of the "Name" window, and if your parent file name is too long it will not grab the full name. :-)

                                I've updated the full script here https://forum.soundflow.org/-1988#post-3 in post 3.

                                I'm glad it will save you some time mate!
                                Rock on!

                                1. JJoachim Jorddal @Joachim_Jorddal
                                    2020-04-29 12:40:16.017Z

                                    Hi again Kitch,
                                    I've been using the script a lot and I'm loving it!

                                    I have come across a small issue. If I have a fade-in at the start of a clip the script interrupts almost instantly and I'm left with a selection of the fade-in.

                                    Here is the error-line from the log:

                                    29.04.2020 14:36:30.79 [Backend]: Error in line 118:
                                    WaitForElementAction
                                    Error: WaitForElementAction
                                    Element was not found or removed after waiting 2000 ms (WaitForElementAction)

                                    Any idea what's causing this? Let me know if you need a screencap to see what's going on.

                                    Best Joachim

                                    1. Kitch Membery @Kitch2020-04-30 01:04:05.632Z

                                      Ahh yes... I never use fades for the purpose I'm using this script for.

                                      I'll update the above script to take care of that by adding the following code;

                                          //Check that first selection is a full clip and not a fade by checking to see if menu item "Loop..." is enabled
                                          //If the first selection is a fade, extend the region selection to the region end.
                                          if (!sf.ui.proTools.getMenuItem("Clip", "Loop...").isEnabled) {
                                              sf.keyboard.press({
                                                  keys: "shift+tab",
                                              });
                                          };
                                      
                                      

                                      Rock on!

                                      1. RRobert Schoen @Robert_Schoen
                                          2023-03-13 18:54:29.043Z

                                          works perfect here even with fades THANKS A LOT!!!

                                          1. RRobert Schoen @Robert_Schoen
                                              2023-03-13 19:12:42.072Z

                                              too early... ust working the first time, than I get an error message ...
                                              Element was not found or removed after waiting 2000 ms
                                              any ideas?

                                              1. Kitch Membery @Kitch2023-03-13 19:27:29.780Z

                                                Hi @Robert_Schoen,

                                                The best way to get help with a script is by using the Red "Need Help?" button in the SoundFlow, please see the following article/video for how to do this.

                                                bit.ly/sfscripthelp

                                                Thanks in advance.

                                                1. RRobert Schoen @Robert_Schoen
                                                    2023-03-13 19:48:54.342Z

                                                    thanks for the quick reply! just did the "Need help" action

                                                  • In reply toRobert_Schoen:
                                                    Kitch Membery @Kitch2023-03-13 19:29:52.717Z

                                                    Also if possible, please provide a screen recording of the script failing. That will help with troubleshooting. :-)

                            • In reply toKitch:
                              AAlex Pasco @Alex_Pasco
                                2021-04-29 22:55:02.176Z

                                Hi Kitch,

                                Thanks for this script!

                                I'd like to modify it and I was wondering if you could assist.

                                I've made and named a few hundred drum samples. they are all on one track of the timeline. I'm going to edit the fronts, fade the tails, and rename everything to unique clip names. (ie, Kick felt 1, kick felt 2, kick wood 1, kick wood 2, snare bright 1,2,3 etc.)

                                I then want to use this script to go through and consolidate and rename each clip, but I want the name to be the old clip name, not the parent name.

                                Any help would be greatly appreciated.

                                Thanks!
                                Alex

                                1. NNoah Hunt @Noah_Hunt
                                    2021-09-24 22:36:41.000Z

                                    I would love to have this operational on my deck!

                                    Can someone paste the working script in full without copy and paste instructions?