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

Batch "Artboards to Files" to multiple files without popup

Explorer ,
Nov 23, 2024 Nov 23, 2024

Copy link to clipboard

Copied

I delete file name everytime and uncheck "Selected Artboard only"I delete file name everytime and uncheck "Selected Artboard only"

I have 100 files and one by one need to Export > Artboards to Files... 100 times. Can i do with jsx or something like that? I use same settings everytime. I dont need to be change it.

Windows, PS 2025

TOPICS
Windows

Views

96

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 , Nov 24, 2024 Nov 24, 2024

This script will save the artboards as TIFF. Each file is named after the artboard, so if two files have the same artboard name the previous file will be overwritten with the next.

 

It saves to a hardcoded location on line 11:

 

    outputFolder = Folder('~/Desktop/');

 

You can change this if needed.

 

Have a single file open and then record the execution of the script into an action. The action should also have a step to close the active document without saving changes. So only two steps in

...

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 23, 2024 Nov 23, 2024

Copy link to clipboard

Copied

@Laf Tasarim Ofisi 

 

Artboards to Files is a script, so it can be edited... It is designed to have a graphical user interface, the code is too complex to remove the GUI easily.

 

Make a backup of the "ArtboardExport.inc" file in the application's Presets/Scripts folder so that you can easily recover it.

 

Here are examples of code lines 502-503, where the "File Name Prefix" is populated:

 

  // File Name prefix.
  dlgMain.etFileNamePrefix = dlgMain.grpTopLeft.add('edittext', undefined, exportInfo.fileNamePrefix.toString())

 

Change line 503 to:

 

  dlgMain.etFileNamePrefix = dlgMain.grpTopLeft.add("edittext", undefined, "");

 

_____________

 

Here are examples of code lines 115-124 for orientation for the "Export Selected Artboards" checkbox:

 

  var origDoc = app.activeDocument
  var sel_indxs = getSelectedLayersAMIdx(origDoc)
  var abArray
  // check to see if selected layers are artboards have artboardID.
  var abArSelected = getArtBoards(sel_indxs)
  if (abArSelected.length === 0) {
    var isSelection = false
  } else {
    var isSelection = true
  }

 

You can change the second last line #123 in the "else" block from true to false:

 

var isSelection = false

 

Or comment out to disable:

 

// var isSelection = true

 

Which will disable the "Export Selected Artboards" checkbox (or ensure that no artboards are selected in the file so that this checkbox isn't activated).

 

_____________

 

An alternative option is to use a custom script rather than the Adobe script.

 

Here is an example for PSD, it doesn't have an interface, but it does have a popup to select a folder. This can easily be replaced with a static save location so that you can record this script into an action and then run it via the Batch command:

 

// artboardsToPSD.jsx - Adobe Photoshop Script
// Version: 0.6.0
// Requirements: Adobe Photoshop CC 2015, or higher
// Author: Anton Lyubushkin (nvkz.nemo@gmail.com)
// Website: http://lyubushkin.pro/
// ============================================================================
// Installation:
// 1. Place script in:
//    PC:  C:\Program Files\Adobe\Adobe Photoshop CC#\Presets\Scripts\
//    Mac:     <hard drive>/Applications/Adobe Photoshop CC#/Presets/Scripts/
// 2. Restart Photoshop
// 3. Choose File > Scripts > artboardsToPSD
// ============================================================================

//#target photoshop

app.bringToFront();

var docRef = app.activeDocument,
    allArtboards,
    artboardsCount = 0,
    inputFolder = Folder.selectDialog("Select a folder to process");

if (inputFolder) {
    function getAllArtboards() {
        try {
            var ab = [];
            var theRef = new ActionReference();
            theRef.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID("artboards"));
            theRef.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
            var getDescriptor = new ActionDescriptor();
            getDescriptor.putReference(stringIDToTypeID("null"), theRef);
            var abDesc = executeAction(charIDToTypeID("getd"), getDescriptor, DialogModes.NO).getObjectValue(stringIDToTypeID("artboards"));
            var abCount = abDesc.getList(stringIDToTypeID('list')).count;
            if (abCount > 0) {
                for (var i = 0; i < abCount; ++i) {
                    var abObj = abDesc.getList(stringIDToTypeID('list')).getObjectValue(i);
                    var abTopIndex = abObj.getInteger(stringIDToTypeID("top"));
                    ab.push(abTopIndex);

                }
            }
            return [abCount, ab];
        } catch (e) {
            alert(e.line + '\n' + e.message);
        }
    }

    function selectLayerByIndex(index, add) {
        add = undefined ? add = false : add
        var ref = new ActionReference();
        ref.putIndex(charIDToTypeID("Lyr "), index + 1);
        var desc = new ActionDescriptor();
        desc.putReference(charIDToTypeID("null"), ref);
        if (add) desc.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelection"));
        desc.putBoolean(charIDToTypeID("MkVs"), false);
        executeAction(charIDToTypeID("slct"), desc, DialogModes.NO);
    }

    function ungroupLayers() {
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
        desc1.putReference(charIDToTypeID('null'), ref1);
        executeAction(stringIDToTypeID('ungroupLayersEvent'), desc1, DialogModes.NO);
    }

    function crop() {
        var desc1 = new ActionDescriptor();
        desc1.putBoolean(charIDToTypeID('Dlt '), true);
        executeAction(charIDToTypeID('Crop'), desc1, DialogModes.NO);
    }

    function saveAsPSD(_name) {
        var psd_Opt = new PhotoshopSaveOptions();
        psd_Opt.layers = true; // Preserve layers.
        psd_Opt.embedColorProfile = true; // Preserve color profile.
        psd_Opt.annotations = true; // Preserve annonations.
        psd_Opt.alphaChannels = true; // Preserve alpha channels.
        psd_Opt.spotColors = true; // Preserve spot colors.
        app.activeDocument.saveAs(File(inputFolder + '/' + _name + '.psd'), psd_Opt, true);
    }

    function main(i) {
        selectLayerByIndex(allArtboards[1][i]);
        var artboardName = app.activeDocument.activeLayer.name;
        executeAction(stringIDToTypeID("newPlacedLayer"), undefined, DialogModes.NO);
        executeAction(stringIDToTypeID("placedLayerEditContents"), undefined, DialogModes.NO);
        app.activeDocument.selection.selectAll();
        ungroupLayers();
        crop();
        saveAsPSD(artboardName);
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }

    allArtboards = getAllArtboards();

    artboardsCount = allArtboards[0];

    for (var i = 0; i < artboardsCount; i++) {
        docRef.suspendHistory('Save Artboard as PSD', 'main(' + i + ')');
        app.refresh();
        app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
    }
}

 

An example for WebP here:

 

 
One can change the PSD or WebP code examples to use TIFF instead.

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 ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

Thank you very much. It works. It isn't like i imagine. I love the PSD version but i cant convert to TIF.

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
Community Expert ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

Now that you have confirmed that the PSD version is what you are looking for, I'll adapt it to TIFF using the settings from your screenshots.

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
Community Expert ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

This script will save the artboards as TIFF. Each file is named after the artboard, so if two files have the same artboard name the previous file will be overwritten with the next.

 

It saves to a hardcoded location on line 11:

 

    outputFolder = Folder('~/Desktop/');

 

You can change this if needed.

 

Have a single file open and then record the execution of the script into an action. The action should also have a step to close the active document without saving changes. So only two steps in the action.

 

Then use File > Automate > Batch and select the action set and action to run and the input folder to process. The destination can be set to none as the script is taking care of the save location and name.

 

// Artboards to TIFF for Batch.jsx
// based on:
// artboardsToPSD.jsx - Adobe Photoshop Script
// Version: 0.6.0

#target photoshop;

var docRef = app.activeDocument,
    allArtboards,
    artboardsCount = 0,
    outputFolder = Folder('~/Desktop/');

if (outputFolder) {
    function getAllArtboards() {
        try {
            var ab = [];
            var theRef = new ActionReference();
            theRef.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID("artboards"));
            theRef.putEnumerated(charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
            var getDescriptor = new ActionDescriptor();
            getDescriptor.putReference(stringIDToTypeID("null"), theRef);
            var abDesc = executeAction(charIDToTypeID("getd"), getDescriptor, DialogModes.NO).getObjectValue(stringIDToTypeID("artboards"));
            var abCount = abDesc.getList(stringIDToTypeID('list')).count;
            if (abCount > 0) {
                for (var i = 0; i < abCount; ++i) {
                    var abObj = abDesc.getList(stringIDToTypeID('list')).getObjectValue(i);
                    var abTopIndex = abObj.getInteger(stringIDToTypeID("top"));
                    ab.push(abTopIndex);
                }
            }
            return [abCount, ab];
        } catch (e) {
            alert(e.line + '\n' + e.message);
        }
    }

    function selectLayerByIndex(index, add) {
        add = undefined ? add = false : add
        var ref = new ActionReference();
        ref.putIndex(charIDToTypeID("Lyr "), index + 1);
        var desc = new ActionDescriptor();
        desc.putReference(charIDToTypeID("null"), ref);
        if (add) desc.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelection"));
        desc.putBoolean(charIDToTypeID("MkVs"), false);
        executeAction(charIDToTypeID("slct"), desc, DialogModes.NO);
    }

    function ungroupLayers() {
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
        desc1.putReference(charIDToTypeID('null'), ref1);
        executeAction(stringIDToTypeID('ungroupLayersEvent'), desc1, DialogModes.NO);
    }

    function crop() {
        var desc1 = new ActionDescriptor();
        desc1.putBoolean(charIDToTypeID('Dlt '), true);
        executeAction(charIDToTypeID('Crop'), desc1, DialogModes.NO);
    }

    function saveAsTIFF(theName) {
        tiffSaveOptions = new TiffSaveOptions();
        tiffSaveOptions.embedColorProfile = true;
        // ByteOrder.MACOS or ByteOrder.IBM
        tiffSaveOptions.byteOrder = ByteOrder.IBM;
        tiffSaveOptions.transparency = true;
        tiffSaveOptions.layers = true;
        tiffSaveOptions.layerCompression = LayerCompression.ZIP;
        tiffSaveOptions.interleaveChannels = true;
        tiffSaveOptions.alphaChannels = true;
        tiffSaveOptions.annotations = true;
        tiffSaveOptions.spotColors = true;
        tiffSaveOptions.saveImagePyramid = false;
        // NONE | JPEG | TIFFLZW | TIFFZIP
        tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
        app.activeDocument.saveAs(File(outputFolder + '/' + theName + '.tif'), tiffSaveOptions, true);
    }

    function main(i) {
        selectLayerByIndex(allArtboards[1][i]);
        var artboardName = app.activeDocument.activeLayer.name;
        executeAction(stringIDToTypeID("newPlacedLayer"), undefined, DialogModes.NO);
        executeAction(stringIDToTypeID("placedLayerEditContents"), undefined, DialogModes.NO);
        app.activeDocument.selection.selectAll();
        ungroupLayers();
        crop();
        saveAsTIFF(artboardName);
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }

    allArtboards = getAllArtboards();

    artboardsCount = allArtboards[0];

    for (var i = 0; i < artboardsCount; i++) {
        docRef.suspendHistory('Save Artboard as TIFF', 'main(' + i + ')');
        app.refresh();
        app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
    }
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

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 ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

LATEST

Thank you very much. 
I change the export folder "docRef.path;" from desktop.

Not it works for me.

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