No internet connection
  1. Home
  2. How to

Preset Select in Batch Rename

By Geoff McGarvey @Geoff_McGarvey
    2021-04-01 01:37:28.852Z

    Hi,
    I have the Batch Rename window opening, but I'd like to automatically select a preset (say; SFX) then click ok. I've tried a few ways with Click UI Element/Select Popup with no success. Any ideas? I'm sure its easy but not a newbie....

    Here's the code so far;

    sf.ui.proTools.appActivateMainWindow();
    sf.ui.proTools.selectedTrack.titleButton.popupMenuSelect({
    isRightClick: true,
    menuPath: ['Batch Rename...']
    });

    • 6 replies
    1. Hey Geoff!

      Here you go!

      /** @param {string} presetMenuPath */
      function batchTrackRenameWithPreset(presetMenuPath) {
          // Identify Batch Track Rename window
          const batchTrackRenameWin = sf.ui.proTools.windows.whoseTitle.is("Batch Track Rename").first;
      
          // Launch Batch Track Rename
          sf.keyboard.press({ keys: "alt+shift+r" });
      
          // Wait for Batch Track Rename to appear
          batchTrackRenameWin.elementWaitFor();
      
          // Select preset
          batchTrackRenameWin.children.whoseRole.is("AXMenuButton").whoseTitle.is("Librarian menu").first.popupMenuSelect({
              menuPath: [presetMenuPath],
          });
      
          // Click "OK" and wait for window to close
          batchTrackRenameWin.buttons.whoseTitle.is("OK").first.elementClick();
          batchTrackRenameWin.elementWaitFor({ waitForNoElement: true });
      }
      
      batchTrackRenameWithPreset('<factory default>');
      

      Just add the preset name to the last line. Following your SFX example, it would look like:

      batchTrackRenameWithPreset('SFX');
      
      1. Geoff McGarvey @Geoff_McGarvey
          2021-04-02 05:11:37.097Z

          Hi Raphael,

          Thanks so much for taking the time and effort to write this code (and the helpful how to comments!). I really appreciate your kindness. I’ll be back in the studio on Tuesday and give it a run. Thanks again and all the best to you!

          Geoff

          1. No problem! Let me know if you need help with anything else!

        • In reply toGeoff_McGarvey:
          Geoff McGarvey @Geoff_McGarvey
            2021-04-06 00:43:29.623Z

            Hi Raphael,

            Thanks again for the code. It isn't quite working though. I'm getting this;

            So it brings up the Batch Rename window but faults there. Here's the window (I selected 'SFX')

            I've tried with another preset name but with the same outcome. Factory Default just comes up with 'new names same as old' as its not chnaging anything. I'd appreciate your help with this one, but if you're busy, no issue.
            Thanks again,
            Geoff

            1. Oh no! Okay, I think I see the issue. The error says it couldn't find the menu item with the name <SFX>, but the preset on the screenshot reads SFX (without the <>). Can you double-check that you typed it in correctly? It should look like this:
              batchTrackRenameWithPreset('SFX');

              1. Geoff McGarvey @Geoff_McGarvey
                  2021-04-06 01:28:37.359Z

                  You are the best! Problem solved!! Sorry I figured , <&> were a code thing but of course they're just in the default name.
                  Thanks so much Raphael.