Copy link to clipboard
Copied
So I've written a simple Action to expand the artboard to enclose all objects. Seems to work just fine. Ran it on a small folder of my AI files as a Batch to test it. Works great. The only issue is that if one of my AI documents contains an image (JPG usually), the Batch pauses and I get an alert box saying "Could not find the linked file…" and it names the missing JPG and gives me options to Replace, Ignore, or Cancel. I went ahead and selected "Apply to All" and clicked "Ignore," and the Batch proceeds cleanly with that particular file. But then I get that alert on every other file it comes across that has a missing image. I did a little searching, and found this thread: https://community.adobe.com/t5/illustrator-discussions/prompt-alert-is-stopping-a-batch-action/m-p/1... which looked really promising. The solution proposed there is from this thread: https://community.adobe.com/t5/illustrator-discussions/save-amp-close-alert-dialogue/m-p/10924804#M1... which suggests adding a line to the Action that runs a simple script that just contains the line
UserInteractionLevel.DONTDISPLAYALERTS;
I've never done any scripting in Illustrator, but I gave it a shot. Took me a few tries to get the script recognised by Illustrator, but I think I finally got it in the right format (plain text) and the right file extension (.jsx) so that it shows up in Illustrator's Scripts menu. I used the Insert Menu Item command in the Actions panel to add that script to the first line of my Action, and tested the Batch again. I still get the "Could Not Find the Linked File" alert pausing the Action. So I did some more searching and found that somebody else was using the script
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
so I tried that instead, and still got the alert that paused my Action.
So is there any way to suppress this alert while running my Batch Action? I've got about 4GB of files I need to apply this action to, and it'd be a lot easier and quicker if I didn't have to sit and acknowledge every alert box.
Thanks for your suggestions!
Wow, 30 years of experience is great!!
You can try the following script
function main() {
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var _rootFolder = Folder.selectDialog();
if (_rootFolder) {
processAction(_rootFolder);
}
}
function processAction(folder) {
var _files = folder.getFiles('*');
for (var f = 0; f < _files.length; f++) {
if (_files[f] instanceof Folder) {
processAction(_files[f])
} else if (_files[f]
...
Do you have the same problem with unfinished files if you turn off Save Files in Background in Preferences?
Hi @thobgood - Here is the new version,
function main() {
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var _rootFolder = Folder.selectDialog();
if (_rootFolder) {
processAction(_rootFolder);
}
}
function processAction(folder) {
var _files = folder.getFiles('*');
for (var f = 0; f < _files.length; f++) {
if (_files[f] instanceof Folder) {
processAction(_files[f])
} else if (_files[f].name.indexOf('.ai') != -1) {
...
Copy link to clipboard
Copied
Hi,
Is it possible to share your script and action and one sample file.
I am not 100% sure without looking the code, but may be try catch block will help you.
Copy link to clipboard
Copied
Sure! I'll try to attach the files here. Thank you so much for taking the time to help. I reall appreciate it.
The forum wouldn't let me attach the .jsx files, so I took the .jsx suffix off and changed them to .txt for the purpose of sharing them here (but they are suffixed .jsx on my end, and reside in the Presets/Scripts folder). I didn't know how to share my actual Action, so I screencapped it and am including it here as a PNG. Please let me know if I should share something different. Thank you again!
Oh, and I'm using Illustrator 27.5 on a M1 Mac running Ventura 13.4, if that makes any difference. Thanks!
Copy link to clipboard
Copied
Accidentally hit reply too soon! I got an error saying my sample AI file wouldn't upload. I attached the error message in the previous reply. If you'd like to test the AI file, you can access it from my Dropbox here: https://www.dropbox.com/s/e0x7hcgji1hz6pd/figuringplates.ai?dl=0
Copy link to clipboard
Copied
@thobgood - You can upload the jsx file with action file on dropbox as well.
Copy link to clipboard
Copied
I think what you are doing, is not calling the actions form the script. I don't see any content in the text file accept the alert line.
To save an action :
1. Select an action.
2. Save an action from the flyout menu of the Actions panel. See screenshot
3. Save it on your desktop with any name
4. Share on dropbox.
Copy link to clipboard
Copied
You can aslo try following
1. Delete suppressalerts from your action.
2. Add folloing code in you jsx file
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
app.doScript('[Action_Name]', '[Action_Group_Name]');
3. In you jsx file replace
Copy link to clipboard
Copied
I shall try adding the code you suggested. Thank you very much.
Once I do that, I'm guessing I would just run this new script, rather than directly running the Action? But then how would I run it as a Batch on my intended folder and all its subfolders? (Apologies for my ignorance; I've worked with Illustrator for thirty years, but have almost never used any sort of Actions or scripting.) Thank you.
Copy link to clipboard
Copied
Aha! That's very smart! I've now saved my jsx files and Action file into my Dropbox. Here are the three links:
https://www.dropbox.com/s/08jvtxr9m8qwlnm/suppressalerts.jsx.js?dl=0
https://www.dropbox.com/s/7evcz065czetg69/suppressalerts2.jsx.js?dl=0
https://www.dropbox.com/s/c5n5al276foqw73/My%20Actions.aia?dl=0
Copy link to clipboard
Copied
Wow, 30 years of experience is great!!
You can try the following script
function main() {
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var _rootFolder = Folder.selectDialog();
if (_rootFolder) {
processAction(_rootFolder);
}
}
function processAction(folder) {
var _files = folder.getFiles('*');
for (var f = 0; f < _files.length; f++) {
if (_files[f] instanceof Folder) {
processAction(_files[f])
} else if (_files[f].name.indexOf('.ai') != -1) {
app.open(_files[f]);
app.doScript('Expand Artboard', 'My Actions');
}
}
}
main();
The above version of the script allows you to choose the folder, So, choose root folder as you select in Batch, the above script will process each files in the folder and subfolders, open without showing the alert and call your action. I hope it helps.
Let me know if you have any issues.
Copy link to clipboard
Copied
AAAAAHHHHH!!! You are both BRILLIANT and GENEROUS! Thank you so much Mr. Rajput! I just dropped your code into a plain txt document, changed the suffix to .jsx, copied it into my Illustrator Scripts folder, crossed my fingers, and gave it a try on my small test folder. It worked perfectly! Thank you so much! You've helped me immensely!
If I could trouble you with one more question. After testing your script on my test folder (which just had 3 ai documents loose inside it), it worked perfectly. When I then tried it on a larger test folder (which had some more complex ai documents, contained within various nested subfolders) it still worked fine, but Illustrator left a lot of the documents open and unsaved, rather than saving and closing them as directed by my Action. I did see a little grey strip alert (not a full alert asking for choices, but just a quick message) saying that Illustrator was busy saving the document and would close it when the saving was complete, but when the script completed, there were still a large number of files open with asterixes next to their name, indicating they had not been saved. (Their artboards had indeed been expanded as per the Action.) I'm thinking maybe the whole process is going so quickly that Illustrator might be getting lost as so many windows open up, and thus a bunch of documents just don't get saved? I'm wondering if some sort of momentary pause added to the end of the script's loop might help this? I'm pretty clueless in this scripting world, as I mentioned, so apologies for my ignorance.
For what it's worth, I then went back to my simple test folder, the one with just three ai documents in it, and tried a few tests adding documents within subfolders, and then nest subfolders within those, and every time these tests worked perfectly and left no open documents, so I'm puzzled as to what's going on. In any case, I can certainly just run your excellent script on small subsets of the gigantic directory I have to work with. You've saved me a lot of time and frustration. Thank you so much. I've marked your most recent message as the correct answer. I just wish I could also mark it "brilliant!" 😄
Copy link to clipboard
Copied
Thank you so much 🙂
I am glad that it helps you.
Scripting is not difficuly, when you start doing practice, you will yourself able to do start creating scripts. I am sharing the link of the documenattion, in case you want to read. This may not be the latest version of teh documentation, but it is good if you want to start it.
https://ai-scripting.docsforadobe.dev/
For the large files, I mean I can give it a try to do all steps by scripting instaed of using the action. I cannot tell you the reason why it is happening until I see this issue myself and debug it. But will share another version where no action is used all done by scripting.
Copy link to clipboard
Copied
oh thank you, that looks like a wonderful resource. I appreciate all your kindness!
Copy link to clipboard
Copied
Do you have the same problem with unfinished files if you turn off Save Files in Background in Preferences?
Copy link to clipboard
Copied
Hi @thobgood - Here is the new version,
function main() {
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var _rootFolder = Folder.selectDialog();
if (_rootFolder) {
processAction(_rootFolder);
}
}
function processAction(folder) {
var _files = folder.getFiles('*');
for (var f = 0; f < _files.length; f++) {
if (_files[f] instanceof Folder) {
processAction(_files[f])
} else if (_files[f].name.indexOf('.ai') != -1) {
var _doc = app.open(_files[f]);
app.executeMenuCommand('selectall');
app.executeMenuCommand('Fit Artboard to artwork bounds');
_doc.close(SaveOptions.SAVECHANGES);
// app.doScript('Expand Artboard', 'My Actions');
}
}
}
main();
I have commented the action code line and add 3 new lines that does the same job as an action.
Copy link to clipboard
Copied
Mr. Rajput, you are a GENIUS! That worked FLAWLESSLY! Every file in every subfolder expanded their artboard perfectly, and every file neatly saved itself and politely closed itself afterwards. I didn't have to do any sort of maintenance afterwards. Thank you so much for all your help! You've made this job 1000% easier for me. I appreciate your skills and your kindness! 🙏
I hope you have a wonderful day!
Copy link to clipboard
Copied
What a smart suggestion! That did the trick. Thank you so much!
Copy link to clipboard
Copied
You're welcome