One of our scripts in pipe would need to know what effects are being used in a scene and where those effects are located(.aex file). Currently I am able to get the used effects from my project, but I am unable to access or get the file path to locate the effects files.
if (project) {
var usedEffects = {};
var pluginLocations = '';
for (var i = 1; i <= project.numItems; i++) {
var item = project.item(i);
if (item instanceof CompItem) {
for (var j = 1; j <= item.layers.length; j++) {
var layer = item.layer(j);
if (layer.property('Effects')) {
for (var k = 1; k <= layer.property('Effects').numProperties; k++) {
var effect = layer.property('Effects').property(k);
if (!usedEffects[effect.name]) {
usedEffects[effect.name] = true;
// Plugin details
var possiblePath = findPluginPath(effect.name);
pluginLocations +=
'Effect: ' +
effect.name +
'\nMatch Name: ' +
effect.matchName +
'\nCategory: ' +
effect.category +
'\nPath: ' +
(possiblePath || 'Not Found') +
'\nLocation: ' +
(effect.location || 'Not Found') +
'\n\n';
}
}
}
}
}
}
$.writeln('Used plugins and inferred paths:\n\n' + pluginLocations);
} else {
$.writeln('No project open!');
}
// Function to recursively search a directory for a specific file
function findFileInDirectory(directoryPath, fileName) {
var folder = new Folder(directoryPath);
if (!folder.exists) return null;
var items = folder.getFiles();
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (
item instanceof File &&
isAEXFile(item.name) &&
item.name === fileName.replace(/\s/g, '') + '.aex'
) {
return item.fsName; // Return the full file path
} else if (item instanceof Folder) {
// Recursively search in subfolders
var result = findFileInDirectory(item.fsName, fileName);
if (result) return result;
}
}
return null; // File not found
}
// Function to check if a file name ends with ".aex" (case insensitive)
function isAEXFile(fileName) {
return fileName.toLowerCase().substring(fileName.length - 4) === '.aex';
}
// Function to search standard plugin directories for a specific file
function findPluginPath(pluginFileName) {
var standardPaths = [
'C:/Program Files/Adobe/Common/Plug-ins/',
'C:/Program Files/Adobe/Common/',
'C:/Program Files/Adobe/Adobe After Effects 2024/Support Files/Plug-ins/',
'/Applications/Adobe After Effects 2024/Plug-ins/',
'/Library/Application Support/Adobe/Common/Plug-ins/',
];
for (var i = 0; i < standardPaths.length; i++) {
var filePath = findFileInDirectory(standardPaths[i], pluginFileName);
if (filePath) {
return filePath; // Return the full file path if found
}
}
return null; // File not found in any standard directory
}```
How would I be able to interact further with an effect object to retrieve its file path?
I am assuming after effects is using either the matchName property of an effect to do this or metadata inside the .aex files.
Do note that yes I have the display and match name from the effect object properties, but the .aex file name is not always the EXACT same. It can be shorthand, lowercase, no spaces, etc etc...
Does someone have a suggestion or solution to get the desired data?
Kind regards!