Batch open single file

I’m creating a small panel to perform batch resizing
this small code allows me to open all the files contained in a folder
but I would like to open them one at a time

the flow should be like this:
opens a photo, resizes it, closes the image and opens the other photo,

I have already created the script to resize and save
I only need the function to open one file at a time

this is what I have now

const {app,core: { executeAsModal }} = require("photoshop");
const {storage: { localFileSystem: lfs }} = require('uxp');
const fs = require("uxp").storage.localFileSystem;
input_folder_to_use = await lfs.getEntryWithUrl(my folder) 

all_images_to_use = await input_folder_to_use.getEntries(input_folder_to_use);

for (const current_image of all_images_to_use) {

    const openDocumentToken = await fs.createSessionToken(current_image);
    const open_specified_image_file = {
        _obj: "open",
        null: {
            _path: openDocumentToken,
            _kind: "local"
        }


    };

    await app.batchPlay([open_specified_image_file]);

What happens next in your loop? Is this cut of the pasted script intentional? You can skip the resize and save. Do you close the file after that? Based on what is visible, it seems it should work on files one by one

Karmalaka The above script loads me all the photos that are in the folder I indicated in lgetEntryWithUrl.
He doesn’t upload them to me one at a time but all at once.
The resizing script is not included.
So I need a script that, once the folder has been indicated, opens one file at a time and not all at once as happens now.
I hope I explained myself well.

I’m a bit confused

Do you mean, that even without the for loop it opens the files as soon as you execute this?

input_folder_to_use = await lfs.getEntryWithUrl(my folder) 
all_images_to_use = await input_folder_to_use.getEntries(input_folder_to_use);

Also you didn’t show what you’re doing at the end of your for loop. It’s cut off in the middle in your example

Yes, that’s right once the folder is indicated it opens all the files contained in it. These strings below are the continuation, Where I specify where to save the file.

let myDir = await lfs.getEntryWithUrl(“My folder”); //Mac
let myFile = await myDir.createFile(“pollo.jpg”, { overwrite: true });
await app.activeDocument.saveAs.jpg(myFile, { quality: 12 }, true);

The scaling part is missing which I have yet to see how to fit it into the process.