No internet connection
  1. Home
  2. How to

"smart" pro tools "save as"

By Philip weinrobe @Philip_weinrobe
    2022-01-31 21:17:21.726Z

    hi friends
    ok, here's a fun one i can't figure out.
    i use the following naming convention in my "save as" for versioning:
    SongTitle - Version# - EngineerName - Notes

    i would love to have a script that did the following

    • started the "save as" process
    • found the Version# in the title
    • moved the last number up by one
    • selected all text at the end of the screen up to the right-most "-"
    • that's it! it would the be ready for me to type my "notes"

    example:

    current session: Stairway To Heaven - 3.6 - pw - auto-tuning the vocals
    scripted save-as: Stairway to Heave - 3.6 - pw -

    and the cursor would be flashing, ready for typing, one space after that last dash

    possible? crazy?

    • 7 replies
    1. samuel henriques @samuel_henriques
        2022-01-31 22:27:48.336Z2022-02-01 18:50:00.316Z

        Hello Philip,
        Try this

        
        /**
        * @param {string} name
        */
        function saveSessionAs(name) {
            sf.ui.proTools.menuClick({ menuPath: ["File", "Save As..."] });
        
            const saveAsWin = sf.ui.proTools.windows.whoseTitle.is('Save').first.elementWaitFor({ waitType: "Appear" }, 'Save as Window Didn\'t Open.').element
        
            saveAsWin.textFields.first.value.value = name
        };
        
        
        sf.ui.proTools.appActivateMainWindow();
        sf.ui.proTools.invalidate();
        
        //////    Session name structure  SongTitle - Version# - EngineerName - Notes
        
        const sessionPath = sf.ui.proTools.mainWindow.sessionPath;
        const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
        const songTitle = sessionName.split(" - ")[0]
        const versionNumber = sessionName.split(" - ")[1] || "0"
        const engineerName = sessionName.split(" - ")[2] || "pw"
        
        
        let cleanVersionN = Number(versionNumber.replace(/[.]/g, ''))
        const newVersionNumber = ++cleanVersionN < 10 ? "0." + cleanVersionN : cleanVersionN.toString().split("").join(".")
        
        const newSessionName = songTitle + " - " + newVersionNumber + " - " + engineerName + " - "
        
        
        saveSessionAs(newSessionName)
        
        
        1. MMatt Cahill @Matt_Cahill
            2023-01-12 14:42:42.130Z

            Hi guys,

            Loving this code, wondered if anyone could help me with a slightly simpler version of this! already tried to make some edits to the code but can't get it to quite work right.

            at the moment, say I have "Projectname 06", with my tweaks it comes out as "Projectname 06 01", but I would absolutely love it if it could save up as "Projectname 07", is this possible/easy to do?

            thanks!

            1. samuel henriques @samuel_henriques
                2023-01-27 23:03:06.770Z

                Hello Matt,
                Try this,
                it ill grab the last number in the session name and increment by one. If there is no number, will add 02.

                function saveSessionAs(newSessionName) {
                    sf.ui.proTools.menuClick({ menuPath: ["File", "Save As..."] });
                
                    //////////////////////////Whait for Save as... Window/////////////////////////////
                
                    const saveAsWin = sf.ui.proTools.windows.whoseTitle.is('Save').first.elementWaitFor({ waitType: "Appear" }, 'Save as Window Didn\'t Open.').element
                
                    saveAsWin.textFields.first.value.value = newSessionName
                
                    saveAsWin.buttons.whoseTitle.is('Save').first.elementClick();
                
                    saveAsWin.elementWaitFor({ waitType: "Disappear" }, 'Save as Window Didn\'t Close.');
                }
                
                
                
                
                function getNewSessionName() {
                    sf.ui.proTools.appActivateMainWindow();
                    sf.ui.proTools.invalidate();
                
                    let newSessionName
                    const sessionPath = sf.ui.proTools.mainWindow.sessionPath;
                
                    const sessionName = sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
                
                    let sessionVersion = sessionName.match(/\d+$/)
                
                    if (!sessionVersion) {
                        newSessionName = sessionName + " 02"
                        return newSessionName;
                    };
                
                    let versionNumber = +sessionVersion[0];
                    let cleanSessionName = sessionName.split(/\d+$/)[0];
                
                    let newVersion = ++versionNumber <= 9 ? "0" + versionNumber : versionNumber
                
                    return cleanSessionName + newVersion
                };
                
                let newName = getNewSessionName()
                
                saveSessionAs(newName)
                
                1. MMatt Cahill @Matt_Cahill
                    2023-02-02 10:24:16.977Z

                    Thanks Sam this is perfect!

              • P
                In reply toPhilip_weinrobe:
                Philip weinrobe @Philip_weinrobe
                  2022-02-01 15:20:32.412Z

                  omg this works and is blowing my mind

                  1. PPhilip weinrobe @Philip_weinrobe
                      2022-02-01 15:23:31.673Z

                      here's a highly specific request (if possible!)
                      i actually use decimal system (1.1, 1.2, 1.3....1.9, 2.0)
                      possible for this script to go from 1.9 to 2.0 correctly?
                      if not, i will change my workflow (or i will manually type the right number when going from 9 to 0

                      phil

                      1. samuel henriques @samuel_henriques
                          2022-02-01 18:28:29.591Z2022-02-01 19:01:56.180Z

                          UPDATED,
                          As is, it will do it in the order in the list.
                          If you don't have version number and operator, the script will add them. As long as the song title doesn't have any " - ", this should work.

                          If you have many engineers using this script, and they all have a soundflow account, I can add a bit to always place the engineer name, instead of taking it from the session name.

                          Stairway To Heaven.ptx
                          Stairway To Heaven - 0.1 - pw - .ptx
                          Stairway To Heaven - 0.2 - pw - .ptx
                          Stairway To Heaven - 0.3 - pw - .ptx
                          Stairway To Heaven - 0.4 - pw - .ptx
                          Stairway To Heaven - 0.5 - pw - .ptx
                          Stairway To Heaven - 0.6 - pw - .ptx
                          Stairway To Heaven - 0.7 - pw - .ptx
                          Stairway To Heaven - 0.8 - pw - .ptx
                          Stairway To Heaven - 0.9 - pw - .ptx
                          Stairway To Heaven - 1.0 - pw - .ptx
                          Stairway To Heaven - 1.1 - pw - .ptx
                          Stairway To Heaven - 1.2 - pw - .ptx
                          ...
                          Stairway To Heaven - 1.2.0 - pw - .ptx
                          Stairway To Heaven - 1.2.1 - pw - .ptx
                          Stairway To Heaven - 1.2.2 - pw - .ptx