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

Script not saving file.

Contributor ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

I've been working on a script to loop through my layersets and export them to the desktop. Everything is working but it's not saving the tiff to the temp folder. The other thing I'm wondering about are the tiff save options, how would I add those?  Any help/insight would be appriciated.

 

var doc = app.activeDocument;

// Set up the output location
var folder = new Folder("~/Desktop/TestFolder");
folder.create();

// Check if the document has any layer sets
if (doc.layerSets.length == 0) {
  alert("The document does not have any layer sets!");
}

// Loop through all the layer sets in the document
for (var i = 0; i < doc.layerSets.length; i++) {
  var layerSet = doc.layerSets[i];

  // Set up the output file name and location
  var fileName = layerSet.name + ".tif";
  
  // Skip the layer set named "Book Board"
if (layerSet.name == "Book Board") {
continue;
}

  // Export the layer set as a TIFF file
new File("~/Desktop/TestFolder/" + fileName);

  // Turn off the layer set
  layerSet.visible = false;
}
TOPICS
Actions and scripting

Views

562

Likes

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

Community Expert , Dec 11, 2022 Dec 11, 2022

An example for saving a tiff off of an open file. 

var myDocument = app.activeDocument;
var docName = myDocument.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
saveCopyAsTif (app.activeDocument, "~/Desktop/"+basename+"_x"+".tif");
////// save pdf //////
function saveCopyAsTif (myDocument, thePath) {
// tif options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrd
...

Likes

Translate

Translate
Community Expert ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

Your Script includes no save operation so naturally nothing is being saved. 

Likes

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
Community Expert ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

An example for saving a tiff off of an open file. 

var myDocument = app.activeDocument;
var docName = myDocument.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
saveCopyAsTif (app.activeDocument, "~/Desktop/"+basename+"_x"+".tif");
////// save pdf //////
function saveCopyAsTif (myDocument, thePath) {
// tif options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = false;
// save copy;
myDocument.saveAs((new File(thePath)), tifOpts, true);
};

Likes

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
Contributor ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

LATEST

Ahh, for some reason I was thinking that just using new File() I was generating the file. Thank you!

 

 

Likes

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