• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with an incrementation and exporting script.

New Here ,
Mar 11, 2018 Mar 11, 2018

Copy link to clipboard

Copied

Hi, I'm trying to use the following code to increment a text layer then export the image. It successfully increments, but it's not exporting or throwing an error message. Note: Most of this code isn't mine, and I'm a relative newb.

----------------------------------------------------

var layer = activeDocument.layers[0];

if (layer.kind == 'LayerKind.TEXT') {

for (var i=1; i < 7; i++) {

layer.textItem.contents = i.toString();

sfwPNG24('C:\Users\WS\Pictures\ ' + i + '.png');

}

}

function sfwPNG24(saveFile){

var pngOpts = new ExportOptionsSaveForWeb();

pngOpts.format = SaveDocumentType.PNG;

pngOpts.PNG8 = false;

pngOpts.transparency = true;

pngOpts.interlaced = false;

pngOpts.quality = 100;

activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);

}

TOPICS
Actions and scripting

Views

726

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Mar 12, 2018 Mar 12, 2018

var layer = activeDocument.layers[0];

if (layer.kind == 'LayerKind.TEXT') {

for (var i=1; i < 7; i++) {

layer.textItem.contents = i.toString();

var saveFile = File('/C/Users/WS/Pictures/' + i + '.png');

sfwPNG24(saveFile);

}

};

function sfwPNG24(saveFile){

var pngOpts = new ExportOptionsSaveForWeb();

pngOpts.format = SaveDocumentType.PNG;

pngOpts.PNG8 = false;

pngOpts.transparency = true;

pngOpts.interlaced = false;

pngOpts.quality = 100;

activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,

...

Votes

Translate

Translate
Adobe
Advocate ,
Mar 12, 2018 Mar 12, 2018

Copy link to clipboard

Copied

var layer = activeDocument.layers[0];

if (layer.kind == 'LayerKind.TEXT') {

for (var i=1; i < 7; i++) {

layer.textItem.contents = i.toString();

var saveFile = File('/C/Users/WS/Pictures/' + i + '.png');

sfwPNG24(saveFile);

}

};

function sfwPNG24(saveFile){

var pngOpts = new ExportOptionsSaveForWeb();

pngOpts.format = SaveDocumentType.PNG;

pngOpts.PNG8 = false;

pngOpts.transparency = true;

pngOpts.interlaced = false;

pngOpts.quality = 100;

activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);

}

This should work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 12, 2018 Mar 12, 2018

Copy link to clipboard

Copied

LATEST

Thanks, works like a charm.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines