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

save files in a done folder

Explorer ,
Sep 15, 2016 Sep 15, 2016

Copy link to clipboard

Copied

hi,

i need to save the new .jpg images in same location of the active document in a seperate folder called Done folder.

Right now this script saved the jpegs  in same location without a folder

Kindly help me on this script

#target photoshop;  

if (app.documents.length > 0) {  

    var thedoc = app.activeDocument;  

    // getting the name and location;  

    var docName = thedoc.name;  

    if (docName.indexOf(".") != -1) { 

        var basename = docName.match(/(.*)\.[^\.]+$/)[1]; 

    } else { 

        var basename = docName; 

    };  

    // getting the location, if unsaved save to desktop;  

    try { 

        var docPath = thedoc.path}  

    catch (e) { 

        var docPath = "~/Desktop" 

    };  

    // 

    var layerSets_ = app.activeDocument.layerSets; 

    for (var a =0; a < layerSets_.length; a++) { 

        // turn all layerSets invisible 

        for (var b =0; b < layerSets_.length; b++) { 

            layerSets_.visible = false; 

        } 

        layerSets_.visible = true; 

        // jpg options;  

        var jpegOptions = new JPEGSaveOptions();  

        jpegOptions.quality = 12;  

        jpegOptions.embedColorProfile = true;  

        jpegOptions.matte = MatteType.NONE;  

        //save jpg in layerset name:  

        thedoc.saveAs(new File(docPath+'/'+layerSets_.name+'.jpg'),jpegOptions,true);

        //thanks to xbytor; 

    } 

};

TOPICS
Actions and scripting

Views

996

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
Adobe
Enthusiast ,
Sep 16, 2016 Sep 16, 2016

Copy link to clipboard

Copied

Hi!

Just change this:

thedoc.saveAs(new File(docPath+'/'+layerSets_.name+'.jpg'),jpegOptions,true);

with this:

var outFolder = Folder(docPath+'/Done');

if (!outFolder.exists) outFolder.create();

thedoc.saveAs(new File(outFolder +'/'+layerSets_.name+'.jpg'),jpegOptions,true);

With folders, you have to creat them before using them to put files. If you don't, the file will not be saved.

Hope it helps.

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
Explorer ,
Sep 17, 2016 Sep 17, 2016

Copy link to clipboard

Copied

Thanks Marques

but i also want that files in .tif format also in TIFF

how to replace the .jpg options to .tiff options ??

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
Explorer ,
Sep 17, 2016 Sep 17, 2016

Copy link to clipboard

Copied

So that save my layersets into TIFF files into TIFF FOLDER

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
Enthusiast ,
Sep 18, 2016 Sep 18, 2016

Copy link to clipboard

Copied

Hi, you have that answered on other posts on this forum.

But I send you one of possibilities:

#target photoshop; 

if (app.documents.length > 0) { 

    var thedoc = app.activeDocument; 

    // getting the name and location; 

    var docName = thedoc.name; 

    if (docName.indexOf(".") != -1) {

        var basename = docName.match(/(.*)\.[^\.]+$/)[1];

    } else {

        var basename = docName;

    }; 

    // getting the location, if unsaved save to desktop; 

    try {

        var docPath = thedoc.path} 

    catch (e) {

        var docPath = "~/Desktop"

    }; 

    //

    var layerSets_ = app.activeDocument.layerSets;

    for (var a =0; a < layerSets_.length; a++) {

        // turn all layerSets invisible

        for (var b =0; b < layerSets_.length; b++) {

            layerSets_.visible = false;

        }

        layerSets_.visible = true;

        // TIFF 

        SaveTiff(File(docPath+'/'+layerSets_.name+'.TIFF'));

    }

};

function SaveTiff(saveFile) {

    tiffSaveOptions = new TiffSaveOptions();

    tiffSaveOptions.alphaChannels = false; 

    tiffSaveOptions.annotations = false; 

    tiffSaveOptions.byteOrder = ByteOrder.IBM; 

    tiffSaveOptions.embedColorProfile = true; 

    tiffSaveOptions.imageCompression = TIFFEncoding.NONE; 

    tiffSaveOptions.layerCompression = LayerCompression.RLE; 

    tiffSaveOptions.layers = true; 

    tiffSaveOptions.saveImagePyramid = false; 

    tiffSaveOptions.spotColors = false; 

    tiffSaveOptions.transparency = true; 

    activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE); 

}

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
Explorer ,
Sep 18, 2016 Sep 18, 2016

Copy link to clipboard

Copied

but this script saves all the layersets in everydocument document but i need only one layerset in one document

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
Explorer ,
Sep 18, 2016 Sep 18, 2016

Copy link to clipboard

Copied

it should take only one layergroup from the main document and save it along with background  layer

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
Enthusiast ,
Sep 18, 2016 Sep 18, 2016

Copy link to clipboard

Copied

Do you mind to explain what you want all at once, please?

I cant't guess what layer group you want to save. Do you want the script to as you if there are more than one?

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
Explorer ,
Sep 18, 2016 Sep 18, 2016

Copy link to clipboard

Copied

Right now the script will export each layer group into jpeg .so it will process what are all layer groups available  in the main document.

now the same i need those files in .TIFF format in a separate folder Done 2

i want each layer-group in the main document to be saved as a different files in done folder along with background layer and that layer group of main document.

For example

i opened my Master.tiff document in Photoshop.

It is having multiple layer sets like 1,2,3,4,5.

Now i want to export all these five layer sets into 5 .tiff files along with same background.

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
Explorer ,
Sep 18, 2016 Sep 18, 2016

Copy link to clipboard

Copied

LATEST

#target photoshop 

function main(){ 

if(!documents.length) return; 

var doc = activeDocument; 

var oldPath = activeDocument.path; 

for(var a=0;a<doc.layerSets.length;a++){ 

activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets.name); 

dupLayers(); 

// activeDocument.mergeVisibleLayers();// Merge visible layer 

activeDocument.trim(TrimType.TRANSPARENT,true,true,true,true); 

var saveFile= File(oldPath +"/"+doc.layerSets.name +".psd"); 

SavePSD(saveFile); 

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 

    } 

main(); 

function dupLayers() {  

    var desc143 = new ActionDescriptor(); 

        var ref73 = new ActionReference(); 

        ref73.putClass( charIDToTypeID('Dcmn') ); 

    desc143.putReference( charIDToTypeID('null'), ref73 ); 

    desc143.putString( charIDToTypeID('Nm  '), activeDocument.activeLayer.name ); 

        var ref74 = new ActionReference(); 

        ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); 

    desc143.putReference( charIDToTypeID('Usng'), ref74 ); 

    executeAction( charIDToTypeID('Mk  '), desc143, DialogModes.NO ); 

}; 

function SavePSD(saveFile){  

psdSaveOptions = new PhotoshopSaveOptions();  

psdSaveOptions.embedColorProfile = true;  

psdSaveOptions.alphaChannels = true;   

activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);  

In the above script it duplicates every layer and save it as  psd without background layer but i want it saved as TIFF along with same backgroud  for all documents in a seperate done folder

anyone help me on this to complete this cript

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