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();
Have something to add?