Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Extendscript AE getting the file path of Selected item and passing variable into system.callSystem()

Community Beginner ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

Hello, If I have an item selected in the project panel in AE. Is ther a way to get the filepath of the selcted item and use that path as a variable. Ultimately I'd like to pass that variable (the filepath) as a string into the system.callSystem(); object as a way to quicklook the selected item.  Is this possible? and if so what is the method to read the filepath attribute from whatever item is selected.

 

Thank you in advance for your help on this.

 

TOPICS
Scripting

Views

176

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Apr 10, 2021 Apr 10, 2021
provided that the selected item is a footage item, the corresponding file is app.project.activeItem.file https://ae-scripting.docsforadobe.dev/items/footageitem/#footageitem-file if(app.project.activeItem && app.project.activeItem.file){ // path of the selected footage is app.project.activeItem.file.fsName alert(app.project.activeItem.file.fsName); } else { // nothing, or something that has no file associated with it (like a comp) is selected }

Likes

Translate

Translate
Adobe Community Professional ,
Apr 10, 2021 Apr 10, 2021

Copy link to clipboard

Copied

provided that the selected item is a footage item, the corresponding file is

app.project.activeItem.file

https://ae-scripting.docsforadobe.dev/items/footageitem/#footageitem-file

 

if(app.project.activeItem && app.project.activeItem.file){

  // path of the selected footage is app.project.activeItem.file.fsName
   alert(app.project.activeItem.file.fsName);
}

else {

  // nothing, or something that has no file associated with it (like a comp) is selected

}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

Thanks Mathias this is exactly what I needed, so if I wanted to set that path as a variable, how would is be possible to pass that into a system.callSystem() command? For instance if I had that variable and wanted to run it as part of a system command, would the variable need to be in single quotes or some such syntax to append that variable to a system command?

 thanks you for your help.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

Yes, if you want to use a variable with a path as part of a system command, you have to make sure to quote it properly. Otherwise things like spaces in the path start causing issues. The same as if you run the command in the terminal.

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

Thanks Mathias, yes I was able to make it work with the proper quotations, and adding a properly placed space. the final line for inserting the path as variable, at elast working on OSX, in case anyone looks at this in the future is:

var itemPath = app.project.activeItem.file.fsName;
var sysComm = "my system command " + " " + itemPath;

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 19, 2021 Apr 19, 2021

Copy link to clipboard

Copied

LATEST

Note the space inside the end quotations of "my system command ",  IIRC the sapce was necessary for making the command work it might be specific to the command I am running though. just a heads up

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines