No internet connection
  1. Home
  2. How to

Can you help me fix this?

By Dane Butler @Dane_Butler
    2024-02-09 16:57:25.179Z

    Hi @Chad !

    Hope you've been well! I wanted to see if I could get your help fixing this script? I have a video recording of the error in question that I'm happy to share. This script has been kind of a moving target for sometime. When it errors out sometime it's a result of just user stuff like the find feature being on in the clip list or the pair track and edit section not being on, but sometimes it's not that and it's other things. Unfortunately the documentation is confidential, can I email it to y'all?

    Here's the script....

    function checkNameExistsPrompt() {
    
        const nameUsedPrompt = sf.ui.proTools.confirmationDialog.invalidate().children.whoseRole.is("AXStaticText").whoseValue.is("That name is already used by another file.").first;
        const fileExistPopup = nameUsedPrompt.exists;
        if (fileExistPopup) {
            sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("OK").first.elementClick();
        };
        return fileExistPopup;
    };
    
    
    
    function clipNameReplaceCharacter(clipName) {
    
        let n = 0
        const clipRenameMenu = sf.ui.proTools.getMenuItem("Clip", "Rename...")
        const isClipSelected = clipRenameMenu.isEnabled;
        if (!isClipSelected) return;
    
        // Open Name Window
        clipRenameMenu.elementClick();
    
    
        const nameWindow = () => sf.ui.proTools.windows.invalidate().whoseTitle.is("Name").first
        nameWindow().elementWaitFor();
        if (!nameWindow().exists) return
    
        while (true) {
            if (nameWindow().exists) {
    
                const clipNameTextFields = nameWindow().groups.whoseTitle.is("Name").first.textFields.first;
                //const clipName = clipNameTextFields().value.invalidate().value
                const newClipName = clipName.replace("$", "") + ""
    
                clipNameTextFields.elementSetTextFieldWithAreaValue({ value: newClipName });
    
                nameWindow().buttons.whoseTitle.is("OK").first.elementClick();
    
                if (checkNameExistsPrompt()) {
                    nameWindow().elementWaitFor();
                    //clipNameTextFields = nameWindow().groups.whoseTitle.is("Name").first.textFields.first;
                    clipNameTextFields.elementSetTextFieldWithAreaValue({ value: newClipName + "_" + ++n });
                    nameWindow().buttons.whoseTitle.is("OK").first.elementClick();
                };
                nameWindow().elementWaitFor({ timeout: 500, onError: "Continue" });
    
            } else {
                break;
            };
        };
    };
    
    
    function getClipName() {
        sf.ui.proTools.getMenuItem("Clip", "Rename...").elementClick();
        const nameWindow = sf.ui.proTools.windows.invalidate().whoseTitle.is("Name").first
        nameWindow.elementWaitFor();
        const clipName = nameWindow.groups.whoseTitle.is("Name").first.textFields.first.value.invalidate().value
        nameWindow.buttons.whoseTitle.is("Cancel").first.elementClick();
        nameWindow.elementWaitFor({ waitType: "Disappear" });
        return clipName
    }
    
    const selectTrack = (trackName) => sf.ui.proTools.trackSelectByName({ names: [trackName] });
    const selectedTracks = sf.ui.proTools.selectedTrackNames
    const topTrack = selectedTracks[0]
    const bottomTrack = selectedTracks[1]
    
    
    selectTrack(bottomTrack);
    const bottomTrackClipName = getClipName();
    selectTrack(topTrack);
    clipNameReplaceCharacter(bottomTrackClipName);
    
    
    
    
    
    • 7 replies
    1. Nathan Salefski @nathansalefski
        2024-02-09 19:53:37.664Z

        Seems like there might be a simpler way to do what you're trying to accomplish. What is that exactly? It seems like you want to rename a clip and append the end with an incremented number the name if it exists. Could you walk me through the work flow more specifically I might be able to help in the mean time.

        1. DDane Butler @Dane_Butler
            2024-02-09 19:57:51.526Z

            Hey, like I said I'm happy to submit a video to soundflow if it helps you.

            1. Nathan Salefski @nathansalefski
                2024-02-09 20:19:38.492Z

                A video could be useful but won’t explain fully what you’re trying to accomplish

                1. DDane Butler @Dane_Butler
                    2024-02-09 20:24:32.197Z

                    The macro takes any two clips on two and only two tracks within an edit selection and renames the clip in the top-most track (the track above the other track) and renames it to reflect the same clip and disk name as the track below it minus a $ sign. There is additional code to append the end of the file name additionally if needed. The problem is this code works only 80% of the time, and then periodically will refuse to to name the clip in question. I would settle for something that does the same thing but only renames the clip if it worked 100% of the time. Bonus points if it generated an alert window that said "hey you left the find function on in the clip list, please select two tracks, etc" to help remind you that pro tools isn't set up the way the script would like you to versus just throwing an error. Sometimes everything can be set up behaviorally though and sometimes a file save copy in will fix it, other times not even that.

                    1. DDane Butler @Dane_Butler
                        2024-02-09 20:27:05.763Z

                        Take two mono tracks with two mono clips, name the bottom one with a dollar sign, select them both and launch the script and what the script does should become clear if my description was lacking in detail. Sorry I'm in the middle of editing thousands of lines of VO.

                2. In reply toDane_Butler:
                  Chad Wahlbrink @Chad2024-02-09 21:04:53.255Z

                  Hey @Dane_Butler,

                  I hope you are doing well, too!

                  I'm offline for the next week or so at the moment.

                  In general, I suggest making an example setup that abstracts the sensitive information from specific projects and then using that test setup to create a screen recording that can be shared publicly. That way, any SoundFlow team member or others in the community can help.

                  Also, as Kitch suggested here, it's best to use the Script/Help workflow to get help with specific scripts and macros. This gives the SoundFlow Team access to critical data and log files to help diagnose issues (also – note that these log files are encrypted and only accessible by the SoundFlow team).

                  1. DDane Butler @Dane_Butler
                      2024-02-09 21:42:02.257Z

                      done