Copy link to clipboard
Copied
Hello everyone!
This is my first support post. Thank you all in advance for your help and advice.
So here is our issue:
My question is...is this possible with so many files?
Copy link to clipboard
Copied
Hello everyone!
This is my first support post. Thank you all in advance for your help and advice.
So here is our issue:
My question is...is this possible with so many files?
Copy link to clipboard
Copied
Hi,
Try following snippet
function main() {
var folder = Folder(Folder.desktop + "/New Files");
if (!folder.exists)
folder.create();
for (var i = app.documents.length; i <= app.documents.length; i--) {
try {
var _backgroudLayer = app.documents[i].layers.getByName('background');
_backgroudLayer.remove();
var fileName = app.documents[i].name;
app.documents[i].saveAs(File(folder + "/" + fileName));
app.documents[i].close(SaveOptions.DONOTSAVECHANGES);
} catch (e) {
}
}
}
main()
This script will create a folder on Desktop with name "New Files" and all files will be saved inside the folder "New Files"
Copy link to clipboard
Copied
there are over 1000 files. I don't think they will all be open in Illustrator. I have slightly modified your code
function main() {
var folder = Folder(Folder.desktop + "/New Files");
if (!folder.exists)
folder.create();
var fileList = File.openDialog("Selest Files", "All:*.ai*", true);
for (var i = fileList.length; i <= fileList.length; i--) {
app.open(fileList[i]);
var doc = app.activeDocument;
try {
var _backgroudLayer = doc.layers.getByName('background');
_backgroudLayer.remove();
var fileName = doc.name;
doc.saveAs(File(folder + "/" + fileName));
doc.close(SaveOptions.DONOTSAVECHANGES);
} catch (e) {
}
}
}
main()
Copy link to clipboard
Copied
OK, firstly i would just like to thank you guys for your quick replies.
Secondly, i just got my hands on the files in question and none of them have a layer with the name "background".
But, is there a possibility to delete sub or grouped layers with the standard "<rectangle>" named layers?
Thanks in advance!!
Copy link to clipboard
Copied
if you need to remove the bottom layer but try this
function main() {
var folder = Folder(Folder.desktop + "/New Files");
if (!folder.exists)
folder.create();
var fileList = File.openDialog("Selest Files", "All:*.ai*", true);
for (var i = fileList.length; i <= fileList.length; i--) {
app.open(fileList[i]);
var doc = app.activeDocument;
try {
//var _backgroudLayer = doc.layers.getByName('background');
//_backgroudLayer.remove();
var docLayers= doc.layers;
var n = docLayers.length;
docLayers[n-1].remove();
var fileName = doc.name;
doc.saveAs(File(folder + "/" + fileName));
doc.close(SaveOptions.DONOTSAVECHANGES);
} catch (e) {
}
}
}
main()
if you need to delete only the bottom object, then try this
function main() {
var folder = Folder(Folder.desktop + "/New Files");
if (!folder.exists)
folder.create();
var fileList = File.openDialog("Selest Files", "All:*.ai*", true);
for (var i = fileList.length; i <= fileList.length; i--) {
app.open(fileList[i]);
var doc = app.activeDocument;
try {
//var _backgroudLayer = doc.layers.getByName('background');
//_backgroudLayer.remove();
var pI= doc.pathItems;
var n = pI.length;
pI[n-1].selected;
pI[n-1].remove();
var fileName = doc.name;
doc.saveAs(File(folder + "/" + fileName));
doc.close(SaveOptions.DONOTSAVECHANGES);
} catch (e) {
}
}
}
main()
Copy link to clipboard
Copied
Getting this error message...
Copy link to clipboard
Copied
There is a typo in the loop.
for (var i = fileList.length; i <= fileList.length; i--) {
Should be:
for (var i = fileList.length-1; i >= 0; i--) {
Copy link to clipboard
Copied
Thanks for the updated code. that worked.
but when I try to select the whole folder of EPS files, i get this error now.
Copy link to clipboard
Copied
Ignore the previous message. The errors came from corrupt files. The code is working perfecly.
Thank you all for your help!