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.
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
}
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
}
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.
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.
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;
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
Copy link to clipboard
Copied
Copy link to clipboard
Copied
i use app.project.file and it works very good in 2023 but for after effects 2024 it returns null