What does checkDocSize() do? Is it a heavy function? Progress bar is shown if exeModal takes longer than approx 2 seconds. How long are you searching for the folder? I don’t think you need modal for the picker. Try this:
var exeModal = require('photoshop').core.executeAsModal;
let folder = await fs.getFolder();
const entries = await folder.getEntries();
var files = entries.filter(async entry => {
if (entry.isFile) {
return true;
}
});
await exeModal(batchProcess);
async function batchProcess() {
await app.open(files[0]);
await checkDocSize();
await app.open(files[1]);
await checkDocSize();
}
Also, do you really need to await for exeModal itself?
Yes checkDocSize() function process is longer It is doing lot more things.
Using await for exeModal because I want to synchronize the process for every file one by one.
so, if process is longer than 2 sec then we cannot avoid progress bar?
Just tested and it seems to be working fine file by file with waiting for the delay:
var exeModal = require('photoshop').core.executeAsModal;
var fs = require("uxp").storage.localFileSystem;
let folder = await fs.getFolder()
let entries = await folder.getEntries()
let files = entries.filter(entry => entry.isFile)
function wait(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
exeModal(batchProcess);
async function batchProcess() {
let now = new Date()
for (const file of files) {
await wait(1000)
console.log(`Seconds passed: ${((new Date()) - now) / 1000}`, file.name)
}
}
Although, as expected, progress bar appears after ~2 seconds:
If you use interactive mode, then progress bar is not shown, but Ps is frozen and user cannot interact anyway. This is expected I suppose, because interactive mode is not meant for such cases