No internet connection
  1. Home
  2. How to

Paste top finder window item path into pro tools open... window

By Sean @SeanH
    2018-09-11 19:26:36.007Z2018-09-11 20:08:21.601Z

    hey,

    so i wanted a simple script just to copy the path of whatever my currently open finder window is and paste that into the pro tools open dialog.

    here's what I borrowed from another post regarding this sort of thing:

     var folderPath = decodeURIComponent(sf.appleScript.finder.selection.getItem(0).asItem.path);
    
     sf.keyboard.type({ text: folderPath });
     sf.wait({ intervalMs: 150 });
     sf.keyboard.press({ keys: 'enter' });
    

    and it works ok, but so far has been pretty inconsistent and unreliable. about half the time or less it will work great, but often it will fail and just direct me to the root volumes folder, not what my top level finder window is, or elsewhere. sometimes it tries to paste the full path but doesn't quite finish. and sometimes the command just errors out and doesn't work at all. haven't figured out any rhyme or reason to when it is successful and when its not.

    is there perhaps a better or more refined script to do something basic like this? or are finder commands still a little buggy?

    let me know if there is more info I can provide. thx!

    SF4.4, pts 2018.7, macOS 10.12

    my normal steps are:

    • have desired location loaded as top window in finder

    • import session data, import video, import audio etc etc in pro tools

    • invoke script

    Solved in post #6, click to view
    • 7 replies
    1. Hi @SeanH. Yea that's a great idea for a script, I think it would work well as part of the session management package. I'll take a look, I know we have some more stable code handling open/save dialogs somewhere, just need to dig it out.

      1. ?@anon6770933309
          2018-09-13 11:29:03.272Z

          The ability to change locations in open/save dialogs would be an awesome addition to SF. Like with Default Folder X.

          See attached demo clip. I change the locations via AppleScript and DFX.

          Changing locations in open & save dialogs.mov (75.47 kB)

          1. I completely agree! Also, I think this needs to be core/built-in actions that are natively supported by SF not just scripts we mock together. This could be a core feature

            1. ?@anon6770933309
                2018-09-14 13:26:10.902Z

                Yep! 👍

          2. In reply toSeanH:

            This will be more stable from beta 4.5, using the following function:

            This function will navigate to the folder path specified as the 1st argument in any frontmost application's focused Open/Save dialog.

            function navigateTo(path) {
                //Get a reference to the focused window in the frontmost app:
                var win = sf.ui.frontmostApp.focusedWindow;
            
                //Sanity check - make sure window is either Save or Open dialog
                if (!(win.title.value.indexOf('Save') >= 0 || win.title.value.indexOf('Open') >= 0))
                    throw 'Focused window is not an Open or Save dialog. Title: ' + win.title.value;
            
                //Open the Go to... sheet
                sf.keyboard.type({ text: '/' });
            
                //Wait for the sheet to appear
                var sheet = win.sheets.first.elementWaitFor({ timeout: 500 }, 'Could not find "Go to" sheet in the Save/Open dialog').element;
            
                //Set the value of the combo box
                sheet.comboBoxes.first.value.value = path;    
            
                //Press OK
                sheet.buttons.whoseTitle.is('Go').first.elementClick({}, 'Could not click "Go"');
            
                //Wait for sheet to close
                win.sheets.first.elementWaitFor({ waitForNoElement: true, timeout: 500 }, '"Go to" sheet didn\'t close in time');
            }
            

            To navigate to the current Pro Tools session's folder:

            var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/');
            navigateTo(folderPath);
            

            To navigate to the top Finder window's folder:

            var folderPath = decodeURIComponent(sf.appleScript.finder.selection.getItem(0).asItem.path);
            navigateTo(folderPath);
            
            Reply1 LikeSolution
              1. In reply tochrscheuer:

                These scripts are also published in the Pro Tools Session Management command package.