No internet connection
  1. Home
  2. How to

How to navigate to current session folder in Logic.

By Graham Archer @Graham_Archer
    2020-10-15 12:32:35.286Z

    Desired Workflow

    Press the shortcut CMD+ALT+SHIFT+F and finder will navigate to the current session folder

    Question

    The error I'm getting is that there's a:

    TypeError: Cannot read property 'split' of undefined (Navigate to Current Session Folder line 22)

    So it appears to be an issue with line 22 in the code.

    Command Info

    ID: user:ck1zg7d5g00029h10rsur9c6b:ckgasgpne0000gd10pi42dwqr
    Name: Navigate to Current Session Folder
    

    Source

    var logic = sf.ui.app('com.apple.logic10');
    function navigateToInDialog(path) {
        //Get a reference to the focused window in the frontmost app:
        var win = sf.ui.frontmostApp.focusedWindow;
    
        //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');
    }
    //var folderPath = sf.ui.proTools.mainWindow.sessionPath.split('/').slice(0, -1).join('/');
    var folderPath = logic.mainWindow.sessionPath.split('/').slice(0, -1).join('/');
    if (sf.ui.frontmostApp.focusedWindow.title.value.match(/open|import/i)) {
        navigateToInDialog(folderPath);
    } else {
        sf.system.exec({ commandLine: 'open "' + folderPath + '"' });
        sf.ui.finder.appActivateMainWindow();
        sf.ui.finder.windows.first.elementRaise();
    }
    

    Links

    User UID: EF59CtElieQvuJf45Plcbt1vTkq1

    Feedback Key: sffeedback:EF59CtElieQvuJf45Plcbt1vTkq1:-MJgEqZTU4V3ii2X6Gwg

    Feedback ZIP

    Solved in post #6, click to view
    • 28 replies

    There are 28 replies. Estimated reading time: 12 minutes

    1. Hi Graham

      I'm not sure that you can use the "sessionPath" variable in Logic - it was designed for Pro Tools.

      1. GGraham Archer @Graham_Archer
          2020-10-15 20:32:07.531Z

          Hey Christian,

          Thanks for replying. Ah ok that'll be why it doesn't work then! If it's an easy thing to introduce in a future version of Sound Flow that would be great as I use the same command loads in Pro Tools and find it to be such a time saver.

          I hope you're well.

          g

          1. You may be able to use mainWindow.getString('AXDocument') - I'm not entirely sure if Logic has this functionality or not. Unfortunately, I don't have Logic on my current machine so can't check.
            @Kitch did you ever have something working with Logic and its current open session path?

            1. Kitch Membery @Kitch2020-10-15 21:38:41.007Z

              Hi @Graham_Archer,

              I'll check it out. It should be easy enough :-)

              1. In reply tochrscheuer:
                Kitch Membery @Kitch2020-10-15 22:06:12.702Z

                @Graham_Archer... Thanks for asking this one, Now I can store this for my future logic scripts :-)

                const logic = sf.ui.app('com.apple.logic10');
                const filePath = logic.mainWindow.getString("AXDocument").slice(7, -1);
                const folderPath = filePath.split('/').slice(0, -1).join('/');
                const sessionName = filePath.split('/').slice(-1)[0].split('.logicx')[0];
                const fileExtension = '.logicx';
                
                log(`${folderPath}/${sessionName}${fileExtension}`);
                

                Rock on!

                Reply1 LikeSolution
                1. Kitch Membery @Kitch2020-10-15 22:21:49.079Z

                  Oh... And this will open the Session Folder ;

                  const logic = sf.ui.app('com.apple.logic10');
                  const filePath = logic.mainWindow.getString("AXDocument").slice(7, -1);
                  const folderPath = filePath.split('/').slice(0, -1).join('/');
                  const sessionName = filePath.split('/').slice(-1)[0].split('.logicx')[0];
                  const fileExtension = '.logicx';
                  
                  log(`${folderPath}/${sessionName}${fileExtension}`);
                  
                  //Open current Logic Pro X session folder in Finder
                  sf.directory.open({
                      path: 'file://' + folderPath,
                  });
                  
                  
                  1. GGraham Archer @Graham_Archer
                      2020-10-15 22:33:16.683Z

                      @Kitch You total legend! Thanks so much - I find it such a useful shortcut when grabbing a bounce etc. I hope others find it useful too.

                      g

                      1. Kitch Membery @Kitch2020-10-15 22:39:25.251Z

                        My pleasure mate!

                        FYI This code will open the "Bounces" folder :-)

                        //Open Current Logic Pro X Session Bounce Folder
                        sf.directory.open({
                            path: 'file://' + folderPath + '/Bounces/',
                        });
                        
                      2. In reply toKitch:
                        OOscar Fogelstrom @Oscar_Fogelstrom
                          2021-04-10 07:00:02.111Z

                          Awesome, thanks!

                          1. In reply toKitch:
                            OOscar Fogelstrom @Oscar_Fogelstrom
                              2021-04-10 07:03:04.877Z

                              Is there a way to open a "recent" location too? i.e. I often bounce straight to Dropbox and would like to go there after a bounce to send files

                              1. OOscar Fogelstrom @Oscar_Fogelstrom
                                  2021-04-10 10:40:49.526Z
                                  1. Kitch Membery @Kitch2021-04-10 18:53:35.962Z

                                    Hi @Oscar_Fogelstrom ,

                                    Can you describe how you would find out the recent location manually?

                                    When bouncing are you using a script to choose the destination folder or are you bouncing manually?

                                    Rock on!

                                    1. OOscar Fogelstrom @Oscar_Fogelstrom
                                        2021-04-11 07:50:47.328Z2021-04-11 07:57:10.822Z

                                        Hi @Kitch !
                                        Yeah so, maybe I was a bit unclear.
                                        Manually I would just go to the relevant dropbox location and copy the dropbox link and add to an email.
                                        I am not using a script for bouncing at the moment.
                                        (So my thinking was: Since I always want to do this right after bouncing, maybe there is a way to "get" the latest folder (adress) that I used, either from Logic or Finder)

                                        1. Kitch Membery @Kitch2021-04-11 08:23:42.124Z

                                          Hi @Oscar_Fogelstrom,

                                          Ahh, yeah getting dropbox links is way complex and requires an using a rest API. I'm not sure I can help you out with that one right now.

                                          Collecting the latest bounce folder address at the time of bouncing and storeing it as a global variable would for sure be the best way to go.

                                          For now, here is the method you would use to open the dropbox folder;

                                          sf.directory.open({
                                              path:'/Users/yourUserName/Dropbox/'
                                          });
                                          

                                          Rock on!

                                          1. OOscar Fogelstrom @Oscar_Fogelstrom
                                              2021-04-11 08:24:46.494Z

                                              Awesome, thanks!

                                              1. In reply toKitch:
                                                OOscar Fogelstrom @Oscar_Fogelstrom
                                                  2021-04-11 18:30:05.049Z

                                                  Ok, so another quick question. I realize this might be in the documentation somewhere, but:
                                                  How do I combine actions and scripts in a package?

                                                  1. Kitch Membery @Kitch2021-04-11 19:59:58.690Z

                                                    Hi @Oscar_Fogelstrom,

                                                    If possible, It would be great if you could ask this question in a separate thread as it does not seem to relate to this post's topic. Also if you could provide a bit more information in the new post about what you are trying to achieve that would be helpful.

                                                    Rock on.

                                                    1. OOscar Fogelstrom @Oscar_Fogelstrom
                                                        2021-04-12 07:02:28.012Z

                                                        will do, thanks!

                                          2. In reply toKitch:
                                            AAndrew Skipper @Andrew_Skipper
                                              2021-04-24 23:23:03.956Z

                                              Awesome @Kitch this is sooooo useful

                                              1. In reply toKitch:
                                                AAndrew Sherman @Andrew_Sherman
                                                  2021-04-25 05:13:12.587Z

                                                  This looks like a fantastic script. @Kitch is there any way of doing the same thing but for other applications as well? I'm trying to set up something similar that uses Ableton, Premiere, After Effects etc, but I'm getting stuck after replacing the app ID and file extension.

                                                  1. Kitch Membery @Kitch2021-04-26 11:13:15.560Z

                                                    Hi @Andrew_Sherman,

                                                    I don't have Ableton or After Effects, but for Premiere, this should work, however, I have not tested it thoroughly. :-/

                                                    const app = sf.ui.app("com.adobe.PremierePro.14")
                                                    const mainWindow = app.windows.whoseTitle.contains(".prproj").first
                                                    const sessionDirectoryPath = '/' + mainWindow.title.invalidate().value.replace(/( \*)$/, '').split('/').slice(0, -1).join('/');
                                                    
                                                    sf.directory.open({ path: `${sessionDirectoryPath}` });
                                                    
                                                    1. AAndrew Sherman @Andrew_Sherman
                                                        2021-04-26 11:32:47.200Z

                                                        Ooh this is like magic @Kitch. Soundflow never ceases to amaze me. This is going to be so useful. Thank you.

                                                        1. AAndrew Sherman @Andrew_Sherman
                                                            2021-05-10 12:58:12.759Z

                                                            @Kitch I'm making some progress on doing a multi-app version of this script, however I'm running into a few roadblocks. Would you have any tips on what I might do if the title of the window is too long (and truncated as a result - making it unclear how to get the path for the filename?

                                                            This is how the title of one of my example files shows in the After Effects window:

                                                            After Effects 2021 - /Users/andrewsherman/M ... ndrew Sherman/_Make Perceive/_Work/Flipdish/After Effects
                                                            

                                                            And this is the actual path:

                                                            /Users/andrewsherman/Make Perceive Dropbox/Andrew Sherman/_Make Perceive/_Work/Flipdish/After Effects/
                                                            

                                                            We need the path in order to reveal the parent folder. I've figured out how to remove the first part of the title, but I'm getting stuck as the path is not complete.

                                                            1. Kitch Membery @Kitch2021-05-10 17:56:48.681Z

                                                              Hi @Andrew_Sherman

                                                              Ahh yeah, that's a shame.

                                                              I'll have to see if I can download a trial version of After Effects later this week to see if I can figure it out. You might find that you can assign a shortcut within After Effects to reveal the project in the finder. If a shortcut exists for it it will probably be called something like "Reveal in Finder".

                                                              Let me know if you have any success with that :-)

                                                              Rock on!

                                                              1. AAndrew Sherman @Andrew_Sherman
                                                                  2021-05-10 18:04:04.083Z

                                                                  Hi Kitch, leave it with me for now; no need to go to the trouble of downloading a trial! I was looking at also doing this with other applications and I see Ableton doesn't use the pathname in the window name, so that further complicates things for my own use anyway.

                                                                  I'm thinking of taking a different approach where I first use a trigger to set the "current project" in Finder and then simply open that whenever I need it. I think I know how to script that. But thanks anyway!

                                                                  1. Kitch Membery @Kitch2021-05-10 18:06:00.354Z

                                                                    Sounds good mate. Keep me posted :-)

                                              2. In reply toGraham_Archer:
                                                Kitch Membery @Kitch2024-03-13 23:23:39.688Z

                                                Hi @Graham_Archer & @Andrew_Skipper

                                                I just thought I'd give you a heads up in case you were not aware, recently we added an Official Logic Pro package to SoundFlow that includes, Plugin, Instrument, MIDI FX, and Send loaders + much more. The package is available in the SoundFlow Store and requires Logic Pro 10.8 and above, and SoundFlow 5.7.0.

                                                If you're interested, we'll be holding a webinar tomorrow Thursday 14th March at 11 am PST. If you are interested, be sure to register at the following link:

                                                https://soundflow.org/events/2024-03-logic-pro-webinar

                                                I hope you can attend. :-)

                                                1. GGraham Archer @Graham_Archer
                                                    2024-04-12 14:35:33.234Z

                                                    Hey @Kitch I'm sorry I missed this, I was in a session at the time. I'm really looking forward to exploring the new Logic Pro Package - great work. Please say thank you to the whole team.

                                                    g