No internet connection
  1. Home
  2. How to

Most reliable way to create new playlist

By Tristan Hoogland @Tristan
    2023-11-13 22:29:00.049Z

    Hi all,

    What's the most reliable way to create a new playlist on a selected track? I have a script that works 98-99% of the time with the following script, the issue is once in a while it'll present me with the rename dialog, which I'm assuming is occurring because it's flying so fast with the mouse clicks that it must be double-clicking the track name to present that dialog rather than accessing the little pop up menu with 'New...' as intended. The purpose of the script is to create a new empty playlist, copies a clip up to it, then renames the file. If however the rename track dialog pops up accidentally then the script will fail.

    //Create New Playlist
    function newPlaylist() {
    
        //New Playlist
        sf.ui.proTools.selectedTrack.popupButtons.allItems[1].popupMenuSelect({
            menuPath: ["New..."],
        });
    
    //I'm not sure this even needs to be here/has any real world function.....
        // Wait for a confirmation window (if any). If one appears then is thereAConfirmationWindow will be "true"
        // If  confirmation window fails to appear continue without throwing a error
        const isThereAConfirmationWindow = sf.ui.proTools.confirmationDialog.elementWaitFor({
            timeout: 1000,
            onError: "Continue",
        }).success;
    
        //If there is a confirmation window, click "OK
        if (isThereAConfirmationWindow) {
            sf.ui.proTools.windows.first.buttons.whoseTitle.is("OK").first.elementClick();
        };
    
        pasteClips();
    }
    

    Thanks!

    • 1 replies
    1. Not the safest way, since it's a keyboard shortcut, but an alternative would be to use the stock PT shortcut to call it instead of the popup menu:

      sf.keyboard.press({
          keys: "ctrl+backslash",
      });
      

      Also, there's a handy option in Preferences > Editing > "Suppress Name Dialog When Creating New Playlist", that gets rid of that confirmation dialog, in case you never need it.