No internet connection
  1. Home
  2. How to

Adapt Clip Name And Paste In Bounce Mix Window

By Gabriel Lundh @Gabriel_Lundh
    2021-02-02 18:36:40.362Z

    Hi! I have a script that I have made through compiling forum scripts and from @Kitch 's great lesson on taking text from UI items.

    It does what I want to, except that I would like the script to take the clip name (as it does) and then removing a few lines of text before its pasting the name in the Bounce Mix Window. The Script goes as following:

    sf.ui.proTools.menuClick({
      menuPath: ["View","Other Displays","Clip List"],
      targetValue: "Enable",
    });
    
    function getSelectedClipNamesFromClipList() {
        const clipsTable = sf.ui.proTools.mainWindow.tables.whoseTitle.is('CLIPS').first;
    
        // Get all selected clips
        const selectedClips = clipsTable.children.whoseRole.is("AXRow").allItems.map(row =>
            row.children[1].children.first.value.value).filter(c => c.startsWith('Selected. '));
    
        // Extract clip names
        const clipNames = selectedClips.map(c => c.split('"')[1]);
    
        return clipNames
    };
    
    const selectedClip = getSelectedClipNamesFromClipList()[0];
    
    
    sf.ui.proTools.selectedTrack.trackSetSolo({
        targetValue: "Enable",
    });
    
    sf.ui.proTools.selectedTrack.trackSetMute({
        targetValue: "Disable",
    });
    
    sf.ui.proTools.selectedTrack.trackOutputSelect({
        outputPath: ["bus","bus menu 1-128","∑ TRANSPORT (Stereo)"],
    });
    
    sf.ui.proTools.menuClick({
        menuPath: ["File","Bounce Mix..."],
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.elementWaitFor();
    
    sf.ui.proTools.windows.whoseTitle.is('Bounce Mix').first.textFields.first.elementSetTextFieldWithAreaValue({value:selectedClip});
    
    

    The clips are always namned something like: SongName_ArtistName_Mix_V.1_6_Binaural.BIN
    I would like the script to remove the text "_Binaural.BIN" and the _number (which can be two numbers, like 11 or so, depending of the project version) so that the file name returns SongName_ArtistName_Mix_V.1.

    I know this is a very Java Script basic question, but I hope its not too out of the way for this forum!
    Thank you so much!!
    All the best,
    Gabriel

    Solved in post #2, click to view
    • 4 replies
    1. samuel henriques @samuel_henriques
        2021-02-02 19:07:58.631Z

        Hey @Gabriel_Lundh,

        Try replacing this line:

        const selectedClip = getSelectedClipNamesFromClipList()[0];
        

        With:

        const selectedClip = getSelectedClipNamesFromClipList()[0].split("_").slice(0,-2).join("_");
        

        hope it helps!!

        Reply2 LikesSolution
        1. G
          In reply toGabriel_Lundh:
          Gabriel Lundh @Gabriel_Lundh
            2021-02-02 20:20:00.517Z

            @samuel_henriques, Thank you so much! This works like a charm! I will try to finally understand the split, slice and join terms from now on.

            Thanks for helping out!

            1. Hi Gabriel,

              Here you can see what split, slice and join does on a sample string:

              • split('_') will split the string into an array of strings, separated by each '_' character.
              • slice(0, -2) will take all elements of the array and make a new array, except the last two items (-2)
              • join('_') will take the array elements and join them together as one single string, joining with the '_' character.
              1. GGabriel Lundh @Gabriel_Lundh
                  2021-02-02 21:19:52.149Z

                  Thank you so much Christian!! Such a great explenation! This will certainly be used in the future!

                  Love the community you've created!
                  All the best,
                  Gabriel

              2. Progress
              3. G@Gabriel_Lundh closed this topic 2021-02-02 20:51:29.798Z.
              4. G@Gabriel_Lundh reopened this topic 2021-02-02 20:51:35.863Z.