Copy link to clipboard
Copied
Hi! I have a problems with one script... i need a simple thing - replacing one path of the file to another.
Its really easy for any footage, (little harder for sequence, but still possible).
BUT
How to do this with illustrator/photoshop files that contain layers? If im apply the usual method to them, which I wrote below, then all layers in my project will be replaced with a single file. How to just replace the path, with keep separating the layers in my project ?
I should note that the .ai (or .psd) file in the old path and in the new one are absolutely identical just different path.
// get the current project
var curProject = app.project;
// create undo group
app.beginUndoGroup("Replace Illustrator Footage Path");
// iterate through all the items in the project
for (var i = 1; i <= curProject.numItems; i++) {
var curItem = curProject.item(i);
// check if the item is an Illustrator file
if (curItem.file instanceof File && curItem.file.name.match(/\.ai$/i)) {
// replace the file path
var curFilePath = curItem.file.fsName;
var newFilePath = new File("C:\\Users\\Alienware\\Downloads\\test PbyBM folder\\new\\" + curItem.file.name);
curItem.replace(newFilePath);
// alert the user that the file path has been updated
}
}
alert("File path updated.");
// close undo group
app.endUndoGroup();
Copy link to clipboard
Copied
It is so sad 😞
Copy link to clipboard
Copied
Hi @Oleh BetterMe did you work this out in the end? 🤞
Copy link to clipboard
Copied
Hello! Unfortunately no, it didn’t work out for me(
I tried various scripts, such as File Hunter and Relincker, but even there, the layers of the illustrator file are replaced with a solid file 😞
Copy link to clipboard
Copied
For this to work, the number of layers and the name of the layers must be the same of the ai or psd file. It could only be replaced by a name search which is a rather dangerous workflow. I don't think there are other alternatives atm.
Copy link to clipboard
Copied
"by a name search" you mean by hand ?
I know this... but I need to do it with a script
Copy link to clipboard
Copied
Nope. I meant by script.
You have to 1. Import the file to AE, 2. Loop through all the items in the project window, 3. Find the name of the layer, before replacing it
Copy link to clipboard
Copied
Sounds good and simple, but there is a couples problems
1. What if the original names have been changed in the project panel? Then the new imported name will not match.
2. How to know, wich type of import to use ? The illustrator can be layered or solid...
Copy link to clipboard
Copied
1. Precisely why I said it was dangerous.
2. Precisely why I said the number of layers and the name of the layers must be the same of the ai or psd file and it has to be the same import type.
Since you seem to have experience, I figured you have also checked the tool guide on this?
An ImportAsType enumerated value; read/write. One of:
• ImportAsType.COMP_CROPPED_LAYERS
• ImportAsType.FOOTAGE
• ImportAsType.COMP
• ImportAsType.PROJECT
These are the types of import.
Lots of restrictions for what you want to achieve though.
Copy link to clipboard
Copied
These restrictions are extremely annoying...
I'm actually trying to recreate the Collect function. It somehow knows how to reassign the path of one Illustrator file to a new one.
Thanks for the help)
Copy link to clipboard
Copied
Oh I tried that before. I think I managed to do it by scripting things to save as a mogrt, changing it to a .zip, unpacking it, but it wasn't a very good method because it runs very slowly. Good luck!
https://community.adobe.com/t5/after-effects-discussions/collect-files-scriptable/td-p/11431767
Find more inspiration, events, and resources on the new Adobe Community
Explore Now