Skip to main content
thobgood
Known Participant
June 10, 2023
Answered

Trying to suppress alerts while running a batch action

  • June 10, 2023
  • 1 reply
  • 4932 views

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/10949147 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#M166201 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!

This topic has been closed for replies.
Correct answer Charu Rajput

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) {
            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.

1 reply

Charu Rajput
Community Expert
Community Expert
June 10, 2023

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.

Best regards
thobgood
thobgoodAuthor
Known Participant
June 10, 2023

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!

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
June 12, 2023

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) {
            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.

Best regards