Javascript equivalent to 'Reveal layer source in project'

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
i4n
Posts: 14
Joined: July 8th, 2011, 3:52 pm

Hello All,

Does anyone know the javascript equivalent to 'Reveal layer source in project and be willing to share'?
I've been digging through the normal reading channels and either It's staring me in the face and I'm not seeing it, or I'm just not good enough at this yet...

What I'm trying to do:
Be able to select an AV Layer in the timeline and with one script have it show me the footage's location in Finder

How far I've gotten:
//var getIt = app.project.activeItem.file;
//alert(getIt)
I'm able to get a return of the path of the object by selecting a layer in the Project panel. I know I'm not very close but at this point I'm going in circles. Even a pointer in the right direction would be greatly appreciated.

Thanks
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

What's not working with what you have? Are you asking about file sequences?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

You can find a selected comp layer's filename/path with something like this:

Code: Select all

var theLayer = app.project.activeItem.selectedLayers[0];
alert(theLayer.source.file.fsName);
It sounds like you want to use the "Reveal in Finder" option. There are no exact equivalents to either that or "Reveal Layer Source in Project" in scripting.

If the project window is selected, you can use this undocumented method to do the "Reveal in Finder" bit:

Code: Select all

app.project.item(2).selected = true; // select second item in project
app.executeCommand(app.findMenuCommandId("Reveal in Finder"));
Unfortunately the same thing doesn't work for "Reveal Layer Source in Project", and there isn't a way to make the project window active either.
i4n
Posts: 14
Joined: July 8th, 2011, 3:52 pm

Thanks for the replies. Since there is no way to make the project panel active, is there a way to pass a command outward to the terminal? With the name of the directory I could perform a simple "open "<path>"" command in the mac terminal and get what I want - a new finder window at the directory containing my footage.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Yes, you can execute commands in the terminal by using system.callSystem(). You will need to make sure the "Allow scripts to access network" is checked in AE before you use that command or you will get an error.
Post Reply