No internet connection
  1. Home
  2. How to

Disk Allocation Script

By Matt Friedman @Matt_Friedman
    2022-02-03 20:06:39.043Z

    Hi. I can't get Soundflow to successfully make a change in Disk Allocation.

    All I need is to open the Disk Allocation window, and option click (on let's say the top most item) to set all the tracks to use the same drive.

    I get these sessions from a composer and their disk allocation always comes in screwed up so I constantly need to reset it to my current working drive. Thought soundflow would come to the rescue but SF seems to not be able to interact with the drive popup menu.

    Any help?

    Solved in post #2, click to view
    • 5 replies
    1. Yeah, that table is a bit trickier than usual.

      Give this a try:

      function setDiskAllocation({ rootMediaFolder }) {
          const diskAllocationWin = sf.ui.proTools.windows.whoseTitle.is("Disk Allocation").first;
      
          sf.ui.proTools.menuClick({ menuPath: ['Setup', 'Disk Allocation...'] });
          diskAllocationWin.elementWaitFor();
      
          const firstRowInTable = diskAllocationWin
              .tables.whoseTitle.is("Disc Allocation").first
              .children.whoseRole.is("AXRow").allItems[2]
              .children.whoseRole.is("AXCell").allItems[1]
              .children.whoseRole.is("AXMenuButton").first;
          
      
          // Select all items in table
          firstRowInTable.mouseClickElement({
              isOption: true,
          });
      
          // Assigns new Root Media Folder
          firstRowInTable.popupMenuSelect({
              relativePosition: { x: 20, y: 5 },
              menuPath: [rootMediaFolder]
          });
      
          diskAllocationWin.buttons.whoseTitle.is("OK").first.elementClick();
          diskAllocationWin.elementWaitFor({ waitType: "Disappear" });
      }
      
      setDiskAllocation({
          rootMediaFolder: "Macintosh HD" // <- Set Root Media Folder Here
      });
      
      Reply1 LikeSolution
      1. MMatt Friedman @Matt_Friedman
          2022-02-03 21:51:48.672Z

          Thank you so much. That totally works!

        • G
          In reply toMatt_Friedman:
          Gaston Ibarroule @Gaston_Ibarroule
            2024-07-01 08:06:10.620Z

            Hey! I'm looking for this type of function and it looks very promising I'd need to choose only the selected tracks in the timeline. Is there a way to do this? It could be great if it could just bring me to "Select Folder" and then I finish the process.

            1. GGaston Ibarroule @Gaston_Ibarroule
                2024-07-01 08:07:24.355Z

                @raphaelsepulveda Maybe it's better to tag you.

                1. Hey @Gaston_Ibarroule, give this a try (tested in macOS Ventura, PT 2024.6);

                  function setCustomDiskAllocationOfSelectedTracks() {
                      sf.ui.proTools.appActivateMainWindow();
                      sf.ui.proTools.mainWindow.invalidate();
                  
                      const selectedTrackNames = sf.ui.proTools.selectedTrackNames;
                      const diskAllocationWindow = sf.ui.proTools.windows.whoseTitle.is("Disk Allocation").first;
                  
                       if (!selectedTrackNames.length) {
                          throw "No tracks selected.\nPlease select one or more tracks and try again."
                      }
                  
                      sf.ui.proTools.menuClick({ menuPath: ['Setup', 'Disk Allocation...'] });
                      diskAllocationWindow.elementWaitFor();
                  
                      const table = diskAllocationWindow.tables.whoseTitle.is("Disc Allocation").first;
                      const tableRows = table.children.whoseRole.is("AXRow").map(row => row);
                  
                      const targetRows = tableRows.filter(row => {
                          const staticText = row.children.whoseRole.is("AXCell").first
                              .children.whoseRole.is("AXStaticText").first;
                  
                          return selectedTrackNames.includes(staticText.title.value);
                      });
                  
                      // Select tracks in Disk Allocation Window
                      targetRows.forEach(row =>
                          row.children.whoseRole.is("AXCell").first.elementClick()
                      );
                  
                      // Open up popup menu from the first selected track
                      targetRows[0]
                          .children.whoseRole.is("AXCell").allItems[1]
                          .children.whoseRole.is("AXMenuButton").first
                          .elementClick({ asyncSwallow: true });
                  
                      // Choose the "Select Folder..." option via keyboard
                      sf.keyboard.press({
                          keys: "return",
                      });
                  
                      // Wait for the "Open" window to come up
                      sf.ui.proTools.windows.whoseTitle.is("Open").first.elementWaitFor();
                  }
                  
                  setCustomDiskAllocationOfSelectedTracks();