No internet connection
  1. Home
  2. How to

batch rename script question

By Philip weinrobe @Philip_weinrobe
    2022-02-27 19:27:33.159Z

    a way to make a script ask me for a number and then put that number into the track batch rename suffix field.

    i'm trying to:
    batch rename all selected tracks but have the suffix be entered by the user

    any ideas?
    thanks!
    philip

    • 3 replies
    1. Eric Huergo @Eric_Huergo
        2022-02-27 23:37:35.636Z2022-02-27 23:47:51.334Z

        Hey Philip, not sure but I'm guessing you mean in Pro Tools, correct?

        If so, just in case you're not familiar with it - Pro Tools has a built in function for precisely that called "Batch Track Rename". You can access it by left clicking on a track you currently have selected (It'll apply it to all selected though, no worries) and selecting "Batch Rename..." - alternatively, the better way of doing this is just using the shortcut for that command (on mac: opt+shift+r).

        This might be a much more efficient way of doing this particular task than building a seperate script for it!

        Once in the batch rename dialog you have plenty of options to rename pretty much any way you see fit - check below!

        Hopefully this helps!

        Best, Eric

        Edit - Alternatively, if you have a certain setting you know you're going to want to apply multiple times, you can always build a script that uses this function and just fills out the details as you'd need them! Additional little bit of info though - the batch rename function in pro tools will hold the last entered data for however long you go without restarting Pro Tools!

        2nd Edit - I re-read your post and it seems like you're already familiar with it actually! I would personally make this work by creating a script that first prompts the user with a dialogue box to enter the desired suffix text, stores the value for the suffix text temporarily, launches the batch rename function, selects all text in the particular UI field for suffix, overwrites said text by pasting the variable you entered before in the dialog box, and then proceeds to run the function.

        I would write the code for you but I'm just heading out at the moment - also odds are that one of the wizards on this forum can think up a better way of doing this too haha! Either way, hopefully this at least helps in some way!

        1. PPhilip weinrobe @Philip_weinrobe
            2022-02-28 01:44:16.645Z

            hi eric
            yeah, i know all about the batch track rename. your edit 2 is exactly what i'm looking for.
            that's just above my coding abilities...

            1. Eric Huergo @Eric_Huergo
                2022-02-28 03:10:22.247Z

                Hey Philip, here ya go - I had a crack at making it. Hope this works for you!

                // Identify Batch Track Rename window
                const batchTrackRenameWin = sf.ui.proTools.windows.whoseTitle.is("Batch Track Rename").first;
                
                // First, ask the user for their input
                var suffixtext = prompt(`Ayo, what's the suffix?`);
                
                // Make Sure Pro Tools is being listened to.
                sf.ui.proTools.appActivateMainWindow();
                
                // Launch Batch Track Rename
                sf.keyboard.press({ keys: "alt+shift+r" });
                
                // Wait for Batch Track Rename to appear
                batchTrackRenameWin.elementWaitFor();
                
                // Enter text from dialog box into the suffix
                sf.ui.proTools.windows.whoseTitle.is("Batch Track Rename").first.textFields.allItems[9].elementSetTextFieldWithAreaValue({value:suffixtext});
                
                // Click 'Ok' to Perform Rename
                sf.ui.proTools.windows.whoseTitle.is("Batch Track Rename").first.buttons.whoseTitle.is("OK").first.elementClick();
                

                I got this by stitching together some stuff i found in the forums - If you're interested, here's the links to what I used. ;)

                "Wait for user input?" by @chrscheuer
                Wait for user input? #post-4

                "How to copy the contents of a prompt dialog to a variable" by @chrscheuer
                How to copy the contents of a prompt dialog to a variable #post-2

                "Preset Select in Batch Rename" @raphaelsepulveda
                Preset Select in Batch Rename #post-2

                "How to enter text into a Pro Tools text field - Part 2 - Using Javascript in the SoundFlow Editor" by @Kitch
                https://www.youtube.com/watch?v=uHl_Zxxsjsw&list=PLKWpZOwx5Z3jxnpNo_dQPhDQNRwp7DCNj

                Peace out girl scout, may you have a blessed one. <3