No internet connection
  1. Home
  2. How to

New Playlist & Duplicate Playlist

By John McPhillips @John_McPhillips
    2023-03-29 10:35:21.798Z

    Hi All - does anyone know if there's a macro/script for creating a new playlist or duplicating current playlist when a track is selected?

    Thanks

    John

    • 3 replies
    1. Chris Shaw @Chris_Shaw2023-03-29 20:34:23.959Z2023-03-29 22:56:52.486Z

      This script will create a new playlist for selected tracks.
      Read the comments to modify it to duplicate tracks

      sf.ui.proTools.appActivateMainWindow();
      sf.ui.proTools.mainWindow.invalidate();
      
      // substitute "New..." with "Duplicate..." to duplicate track
      const trackAction = "New..."
      
      //Get selected Track Names
      const originalSelectedTracks = sf.ui.proTools.selectedTrackNames;
      
      //Select first track and make sure it is scrolled into view
      sf.ui.proTools.trackSelectByName({
          names: [originalSelectedTracks[0]]
      })
      
      sf.ui.proTools.selectedTrack.trackScrollToView()
      
      //Reselect originally selected tracks
      sf.ui.proTools.trackSelectByName({ names: originalSelectedTracks })
      
      //Duplicate or Create New Tracks depending on value of `trackAction`
      sf.ui.proTools.selectedTrack.popupButtons.whoseTitle.is("Playlist selector").first.popupMenuSelect({
          isShift: true,
          isOption: true,
          menuPath: [trackAction]
      })
      
      //Delete everything below this line if you want to name the playlist
      //otherwise the script will automatically click "OK" to close confirmation dialog
      
      
      //If only one track is originally selected, wait for the confirmation dialog
      sf.wait({ intervalMs: 300 })
      
      const confDialog = sf.ui.proTools.confirmationDialog
      
      //close conmf dialog
      if (confDialog.exists && originalSelectedTracks.length == 1) {
          sf.ui.proTools.windows.first.buttons.whoseTitle.is("OK").first.elementClick()
      }
      
      1. JJohn McPhillips @John_McPhillips
          2023-03-30 09:10:04.344Z

          Hi Chris - thank you so much, this is exactly what I was after. I'm hopeless at coding/scripting... One day, one day I'll knuckle down and save you all this bother.

          Cheers

          John

        • P
          In reply toJohn_McPhillips:
          Paul Fawcus @Paul_Fawcus
            2024-09-04 13:32:17.062Z

            Thanks for this!