Expressions/Scripts/Presets

Moderator: Paul Tuersley

 
bkan
Topic Author
Posts: 51
Joined: Wed Nov 06, 2013 8:33 am

Run an explorer windows from After effects

Fri Dec 02, 2016 1:34 am

Hello,
I try to run an explorer windows via after effects script. My script is based on this :
 
 var path = tabBtns_foldersSpecific_path[myNumber];
 
    if($.os.indexOf("Win") != -1){ 
    cmd = "explorer " + String(path);
     
    }else{ 
    cmd += (("open \"" + String(myGoodPath)) + "\"");          // change var path for Mac  
    } 
      alert(cmd);
    try { 
    system.callSystem(cmd); 
    }catch (e){ 
    alert(e); 
    } 
 
My « path » variable returns  :“/e/RESSOURCES “
This variable is defined with this command :
Var myFolderPath = Folder.selectDialog();
Path = String(myFolderPath);
 
But After effects does not open the correct folder (it opens the default one : “Documents”).
I tried to do it manually, and what is working is : “e:\\ RESSOURCES “
 
It seems that the good string is with 2 backslashes (“\\”).
Any idea of a solution?
Thank you!
 
runegan
Posts: 19
Joined: Fri Nov 04, 2016 3:18 pm
Contact:

Re: Run an explorer windows from After effects

Fri Dec 02, 2016 4:39 am

This is what I usually use, It should work on both windows and mac:
function revealFile(filePath) {
   if ( filePath instanceof File ) {
      filePath = filePath.fsName;
   }

   var command = "open -R";
   if ($.os.indexOf("Win") != -1) {
      command = "Explorer /select,";
   }
   arg = "\"" + filePath + "\"";
   return system.callSystem(command + " " + arg);
}
 
bkan
Topic Author
Posts: 51
Joined: Wed Nov 06, 2013 8:33 am

Re: Run an explorer windows from After effects

Fri Dec 02, 2016 4:48 am

Hello,
Thank you for your answer. Have you got an example of a string you put in your "filePath" variable?
Thank you!
 
runegan
Posts: 19
Joined: Fri Nov 04, 2016 3:18 pm
Contact:

Re: Run an explorer windows from After effects

Fri Dec 02, 2016 5:06 am

I usually just use a File object, which will be converted to string by this code:
   if ( filePath instanceof File ) {
      filePath = filePath.fsName;
   }

Or strings that are created by accessing file.fsName somewhere else in the code.
 
bkan
Topic Author
Posts: 51
Joined: Wed Nov 06, 2013 8:33 am

Re: Run an explorer windows from After effects

Fri Dec 02, 2016 5:17 am

OK, thank you!
Just another precision : if my string is : ""/e/RESSOURCES/SONS/CARTOONS"", the explorer windows open "/e/RESSOURCES" and select the "CARTOONS" folder instead of going into this folder....!
 
runegan
Posts: 19
Joined: Fri Nov 04, 2016 3:18 pm
Contact:

Re: Run an explorer windows from After effects

Fri Dec 02, 2016 5:27 am

I don't work on a windows machine, but after searching a bit it seems that you will get the desired result by removing "/select,".
 
bkan
Topic Author
Posts: 51
Joined: Wed Nov 06, 2013 8:33 am

Re: Run an explorer windows from After effects

Fri Dec 02, 2016 5:42 am

Oh!! Thanks a lot, it is working!!
 
beginUndoGroup
Posts: 77
Joined: Tue Nov 27, 2012 6:41 am

Re: Run an explorer windows from After effects

Fri Dec 02, 2016 12:31 pm

For folders, you can simply do:

myFolderObj.execute();

For files, .execute() also exists, but it will do something different (open the file with the default application registered for that type of file).

Xavier

Who is online

Users browsing this forum: No registered users and 5 guests