Save jpg file with sequential number

I would like to know how to get with uxp a command to save the jpg file sequentially
with cep I used this script.

main();
function main(){
if(!documents.length) return;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
try{
var savePath = activeDocument.path;
}catch(e){
    alert("Devi salvare prima questo documento!");
    }
var fileList= savePath.getFiles(Name +"*.jpg").sort().reverse();
var Suffix = 0;
if(fileList.length){
    Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix= zeroPad(Suffix + 1, 2);
var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".jpg");
SaveJPEG(saveFile, 12); 
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality; 
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
};
function zeroPad(n, s) { 
   n = n.toString(); 
   while (n.length < s)  n = '0' + n; 
   return n; 
};

How can I have this with uxp?

thanks for your help

@haller … Can you look at this documentation for getFileForSaving(suggestedName, options)

You will have to do something like the one shown below

let fs = require('uxp').storage.FileSystemProvider;
const file = await fs.getFileForSaving("fileName.jpg", { types: [ "jpg" ]});

thanks for the info I’ll take a look at it now.

I’ve tried everything but can’t get it to work If someone could kindly put something that works it would be appreciated.