• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

1.6K

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

Community Expert , 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

}

Votes

Translate

Translate
Community Expert ,
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

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

Votes

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.

Votes

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 Expert ,
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.

 

 

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

Votes

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;

 

Votes

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

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

Votes

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 ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

LATEST

Thank you, this helped with something Im working on. Just for my own knowledge WHAT and WHY fo you have to add the extra + " " in between the "my system comman " and +itemPath ?  Ive attached a picture and underlined the part im talking about        

Votes

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