No internet connection
  1. Home
  2. Support

Copy track names to comments boxes in Pro Tools?

By Graham Archer @Graham_Archer
    2019-09-18 09:07:47.889Z

    Is there a way to get access to the comments boxes in Pro Tools using SF without double clicking on the track name and then using a series of CMD+Right Arrow moves?

    I'd like to be able to copy Track names to comments boxes for selected tracks, for an entire session, and also delete all text written in comments boxes too.

    Please let me know if it's possible! Thanks!

    Solved in post #2, click to view
    • 13 replies
    1. This should do it:

      function setComment(trackHeader, text) {
          var commentsField = trackHeader.textFields.whoseTitle.startsWith('Comments').first;
          commentsField.mouseClickElement();
          sf.keyboard.press({ keys: 'cmd+a' });
          sf.keyboard.type({ text: text });
          sf.keyboard.press({ keys: 'return' });
      }
      
      function setCommentsToTrackNames() {
          var tracks = sf.ui.proTools.selectedTracks.trackHeaders;
          for (var i = 0; i < tracks.length; i++) {
              var track = tracks[i];
              setComment(track, track.normalizedTrackName);
          }
      }
      
      setCommentsToTrackNames();
      
      Reply2 LikesSolution
      1. This is insanely useful for this archival project I working on.
        Thanks

        1. In reply tochrscheuer:
          Chris Shaw @Chris_Shaw2021-01-28 18:11:18.412Z2021-02-02 22:20:25.877Z

          A slightly more robust version that makes sure that the selected track is scrolled into view (otherwise it fails) and opens and closes the comments field if not initially visable:

          function setComment(trackHeader, text) {
              var commentsField = trackHeader.textFields.whoseTitle.startsWith('Comments').first;
              commentsField.mouseClickElement();
              sf.keyboard.press({ keys: 'cmd+a' });
              sf.keyboard.type({ text: text });
              sf.keyboard.press({ keys: 'return' });
          }
          
          function setCommentsToTrackNames() {
              var trackNames = sf.ui.proTools.selectedTrackNames
              var tracks = sf.ui.proTools.selectedTracks.trackHeaders;
              for (var i = 0; i < tracks.length; i++) {
                  var track = tracks[i];
          
                  sf.ui.proTools.trackSelectByName({ names: [trackNames[i]] });
                  sf.ui.proTools.selectedTrack.trackScrollToView({});
                  setComment(track, track.normalizedTrackName);
              }
          }
          sf.ui.proTools.appActivateMainWindow();
          sf.ui.proTools.invalidate();
          let areCommentsVisible = sf.ui.proTools.getMenuItem("View", "Edit Window Views", "Comments").isMenuChecked
          if (!areCommentsVisible) {
              sf.ui.proTools.menuClick({ menuPath: ["View", "Edit Window Views", "Comments"], })
          }
          setCommentsToTrackNames();
          
          if (!areCommentsVisible) {
              sf.ui.proTools.menuClick({ menuPath: ["View", "Edit Window Views", "Comments"], })
          }
          
          1. Revised : Added sf.ui.proTools.invalidate();

            1. NNenad Simsic @Nenad_Simsic
                2023-06-19 11:26:40.832Z

                With PT 2023.6 this script does not work anymore! Is there any chance to have a look into this?

                thanx, Nenad

            2. In reply tochrscheuer:
              MMatt Friedman @Matt_Friedman
                2023-11-06 22:21:10.821Z

                This doesn't seem to work anymore. Looks like SF can no longer click on the Comments Field??? (PT 2023.6)

                1. cc @Kitch - it's likely you'll need to add a slight offset to the mouseClickElement call to make the mouse click happen in the right location.

                  1. MMatt Friedman @Matt_Friedman
                      2023-11-07 17:14:13.991Z

                      I actually found solution in another thread here just changing

                      commentsField.mouseClickElement() to commentsField.elementClick()

                2. A
                  In reply toGraham_Archer:
                  Andrés Giraldo @Andres_Giraldo
                    2021-09-28 16:08:00.306Z

                    What about if you want to do it the other way around? I mean copying the comments to the track name? What should change in the code?

                    Thanks!

                    1. RRyan @Ryno
                        2023-09-05 10:30:01.711Z

                        I'd love this "track names to comments" script to work, I came here to request it and it's not working in the latest builds of Pro Tools

                      • J
                        In reply toGraham_Archer:
                        Judson Crane @Judson_Crane
                          2025-09-05 16:02:58.823Z

                          wondering if there is a new script for this function that is compatible with current version of PT? Thanks!

                          1. Chris Shaw @Chris_Shaw2025-09-07 17:20:09.555Z2025-09-07 17:39:42.399Z

                            This should do it.
                            If alt/option is held while triggering this script it will clear all comments from selected tracks:

                            /**
                             * Sets comments on selected tracks to match their track names.
                             * If Alt is held, comments will be cleared instead.
                             *
                             * @param {boolean} hasAlt - Whether the Alt key is held down.
                             */
                            function setComments(hasAlt) {
                                // Ensure Pro Tools is active and refreshed
                                sf.ui.proTools.appActivateMainWindow();
                                sf.ui.proTools.mainWindow.invalidate();
                            
                                // Get selected tracks
                                const selectedTracks = sf.app.proTools.tracks.invalidate().allItems.filter(t => t.isSelected);
                                if (!selectedTracks.length) throw "No tracks selected";
                            
                                // Scroll first track into view and open rename window
                                const firstTrack = selectedTracks[0];
                                const firstTrackHeader = sf.ui.proTools.trackGetByName({ name: firstTrack.name }).track;
                            
                                sf.ui.proTools.trackSelectByName({ names: [firstTrack.name] });
                                sf.ui.proTools.selectedTrack.trackScrollToView();
                            
                                firstTrackHeader.titleButton.mouseClickElement({ clickCount: 2 });
                            
                                // Wait for the rename window
                                sf.ui.proTools.windows.whoseTitle.is(firstTrack.name).first.elementWaitFor();
                            
                                const renameWindow = sf.ui.proTools.focusedWindow.invalidate();
                            
                                // ─────────────────────────────
                                // Map text fields and buttons
                                // ─────────────────────────────
                                const [trackNameField, commentsField] = renameWindow.textFields.map(x => x);
                                const [okBtn, , , nextBtn] = renameWindow.buttons.map(x => x);
                            
                                // Helper to sync or clear comments
                                function updateComments() {
                                    if (hasAlt) {
                                        commentsField.elementSetTextFieldWithAreaValue({ value: '' });
                                        return;
                                    }
                                    while (trackNameField.value.invalidate().value !== commentsField.value.invalidate().value) {
                                        commentsField.elementSetTextFieldWithAreaValue({
                                            value: trackNameField.value.invalidate().value
                                        });
                                    }
                                }
                            
                                // Process each track
                                selectedTracks.forEach((track, i) => {
                                    updateComments();
                                    const isLast = i === selectedTracks.length - 1;
                                    (isLast ? okBtn : nextBtn).elementClick();
                                });
                            
                                // Reselect all processed tracks
                                sf.app.proTools.selectTracksByName({
                                    trackNames: selectedTracks.map(t => t.name)
                                });
                            
                                // ─────────────────────────────
                                // Final notification
                                // ─────────────────────────────
                                sf.interaction.notify({
                                    title: "Update Track Comments",
                                    message: hasAlt ? "Comments cleared on selected tracks." : "Comments set to track names.",
                                    keepAliveMs: 3000
                                });
                            }
                            
                            // Entry point
                            setComments(event.keyboardState.hasAlt);
                            
                            1. Chris Shaw @Chris_Shaw2025-09-07 17:22:53.046Z2025-09-07 17:58:59.671Z

                              This is a refactor of @samuel_henriques excellent script from this thread:
                              Copy track name and paste to PT scribble strip...
                              I updated it to take advantage of some of the newer SF / PT SDK commands