Skip to main content
Known Participant
April 9, 2021
Answered

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

  • April 9, 2021
  • 1 reply
  • 2994 views

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.

 

This topic has been closed for replies.
Correct answer Mathias Moehl

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

}

1 reply

Mathias Moehl
Mathias MoehlCorrect answer
Community Expert
April 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

}
Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Known Participant
April 16, 2021

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.

Mathias Moehl
Community Expert
April 17, 2021

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.

 

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects