Export files

i’m trying to export multiple versions of my artboards (change text, fit to center etc)
The problem is that when I do loop files just do not export.
I think is a problem with synchronicity, I can be wrong.

QuickExport function

async function quickExport(destFolder, layerOnly = false, fileType) {
  try {
    await batchPlay([
      {
        _obj: layerOnly ? "exportSelectionAsFileTypePressed" : "exportDocumentAsFileTypePressed",
        _target: { _ref: "layer", _enum: "ordinal", _value: "targetEnum" },
        fileType: fileType,
        quality: 90,
        metadata: 0,
        destFolder,
        sRGB: true,
        openWindow: false,
        _options: { dialogOptions: "dontDisplay" },
      },
    ], { synchronousExecution: false })
  } catch(e) {console.error(e)}
}

and applyDataset&export function

var countries =["PL","EN","CZ","SK","DE","RO","HU","LT","LV","EE","HR","RU","UA","FR","ES","IT","SL"];
async function exportThings(){
  for (country of countries) {
    await applyDataSet(country);
    countryFolder = dataFolder.nativePath + '/' + fileName + '/' + country;
    await quickExport(countryFolder, false, "jpg")
  }
}

I can make sleep for couple seconds after every export but its not optimal

change quality: 32 and you will find it work sucessly.

1 Like