Batch Multi Save

JavaScript for Adobe Photoshop
Latest update 6/24/2019, version 2.0.1

The script scans a folder for images, performs selected transformations, and saves copies in up to four common formats. While this functionality is similar to existing scripts (for example, Image Processor, included with Photoshop), Batch Multi Save adds capability missing from other file saving scripts.

  • Process all or selected extensions
  • Process raster images, PDF, AI, and vector EPS
  • PDF first page, all pages, or all images
  • Save PSD, TIF, JPG, and PNG 8 or 24
  • Convert to any color profile
  • Layers as-is, merged, or flatten
  • Adjust PPI, set or resample
  • Limit pixels in either dimension
  • Keep paths, discard all, or keep special cases
  • JPG and PNG rename for web use
  • Save and restore all settings
Batch Multi Save screen
Download
Batch Multi Save

You decide. Reward the author an
amount the solution is worth to you.

The original idea was to automate saving final files after color correction/retouching. My working files are PSD with layers and masks, but the client doesn’t need all that. Most want something for print and web — a single layer or flattened CMYK TIF, and RGB JPG/PNG at lower resolution. Other tools accomplish most of this, but not every step in one tool, or with sufficient control. I wanted more. Also useful for web development, the script can downsample images or extract from PDFs, transform, and save in one operation.

Instructions for use

The interface has four sections: Input, A group of four output formats, Output, and Settings. Enable desired options and click the OK button to begin. A progress bar is displayed while processing. To cancel processing, press the ESC key. Otherwise, when complete, the number of images processed is reported. If any concerns are encountered, a log file is written to the input folder and the user is notified.

Section 1: Input

Folder — select a folder to scan for images. If no image files are found, the user is notified.

Include subfolders — if enabled, images in the selected folder and in every folder below it are processed. If disabled, only images in the selected folder are processed.

Any extension — any file Photoshop is able to open is processed. If Photoshop cannot open a file, the error is reported in the log file. The script ignores a list of extensions we know won’t open (i.e. txt, doc, etc.). Because the script won’t even try, these are not reported in the log file.

Only the extension(s) — files matching extensions in the list are processed. Enter a single extension or separate multiple extensions with a space or comma. The preceding dot is not necessary and if present is ignored.

PDF/AI/EPS options — additional options when the script encounters PDF, Illustrator (PDF compatible), or vector EPS. The script recognizes raster EPS and processes normally, not as vector.

Batch Multi Save screen 2

PDF panel — the choice to rasterize the First page or All pages, or instead extract all Images from the PDF.

Crop to — the page box used to crop the PDF page or Illustrator art. Does not apply to vector EPS, which always crop to the bounding box.

Resolution — pixels per inch used to rasterize the PDF page, Illustrator art, or vector EPS. Does not apply to PDF images, which maintain their original resolution.

Mode — the color space used to rasterize the PDF page, Illustrator art, or vector EPS. Does not apply to PDF images, which maintain their original color space. When vector files are rasterized, the color profile used is determined by the application Color Settings, just as when opening vector files directly in Photoshop. Set the desired color profiles using the menu Edit > Color Settings before launching the script.

Section 2: Group of four output formats

The script outputs images in the formats PSD, TIF, JPG, and PNG. To enable output of a format, click its checkbox Save in folder. Options available vary between formats as described below.

Options common to all output formats

Save in folder — enable the checkbox to save a version of each image in the selected format, then enter a folder name in which the copies are saved (required).

Adjust PPI to — enable the checkbox and enter the desired pixels-per-inch value.

Set/Resample — determines how Photoshop arrives at the entered PPI value. Set does not change the number of pixels, only records how many make up an inch. Resample maintains the current image dimensions (in inches) and increases or decreases the number of pixels to arrive at the entered PPI value. Note Resample method is Automatic.

Maximum pixels, width and height — enable the checkbox to limit the final pixel dimensions of the image, and enter a value in pixels for the width and/or height. It is acceptable to omit one of the dimensions. In that case, the entered dimension is limited and the other falls wherever it may. When both values are entered, neither dimension exceeds the value entered. One dimension may result in fewer pixels than entered if necessary to maintain proportions. In other words, setting both values does not define precise width and height; it only defines the upper limit of each dimension.

IMPORTANT NOTE: if the Maximum pixels option is enabled and Adjust PPI to is also enabled, it is usually best to select Set rather than Resample because PPI is adjusted before evaluating maximum pixels. When PPI is resampled to a low value (i.e. 72), the result might be fewer pixels than the maximum entered. This could be desired behavior, or possibly not. Just know that PPI adjustment happens first, then the image is reduced to limit maximum pixels.

Options unique to particular formats

PSD, TIF, and JPG

Convert to profile — converts color to the selected profile prior to saving a copy of the image. This occurs after merging layers or flattening to ensure any adjustment layers are applied in the original color space before conversion to the selected profile.

Keep all paths, Discard all paths, Keep paths...Keep all paths leaves all paths untouched. Discard all paths removes all paths including any set to clipping path. Keep paths... displays an additional dialog with further options:

Batch Multi Save screen 3

Input field — enter the path names to keep. Separate multiple path names with a comma. Match to path names is case-insensitive

Keep first path, any name — the first path in the Paths panel is retained, regardless of its name.

Keep clipping path — the path assigned to clipping path is retained.

Vector masks: save as paths and keep all — vector mask paths and shape layer paths are copied to normal paths and named incrementally (Path 2, Path 3, etc.). Because other transformations may apply vector masks and rasterize shape layers, which then removes the actual path (for example, merge to single layer or flatten), the copying to a normal path for these elements occurs before other transformations.

PSD and TIF

Layers as-is — layers are untouched and alpha channels are retained, as well as ruler guides. This option does not exist for JPG or PNG. JPG requires the image is flattened. PNG supports a single layer, but not multiple layers, which the input image may have.

IMPORTANT NOTE: This option is disabled when other options are enabled that alter color or pixel dimensions. Adjustment layers cannot change color space and maintain faithful results, and layer effects do not scale when an image is resized. For these reasons, when the corresponding options are enabled, the image must be merged to a single layer or flattened to maintain appearance.

PSD, TIF, and PNG

Single merged layer — hidden layers are discarded and the remaining layers are merged to a single layer. If a layer mask remains, it is applied. Alpha channels and ruler guides are discarded. The option does not exist for JPG as it must be flattened.

Flatten — result is a single “Background” layer. Alpha channels and ruler guides are discarded. JPG always performs this step.

The above two options are performed before resizing so that any effects, smart objects, and shape layers are rasterized at original resolution to maintain appearance.

JPG

Embed color profile — embeds into the JPG the current color profile, either for the original color space if not converted, or the profile selected for the Convert to profile option. The option exists for JPG so that files intended for print can include profiles, important to preserve in that case, but JPG for web may omit profiles, as the profile is excess and only increases file size.

Quality — JPEG image quality. Valid range is from 0 to 12. 0 is extreme compression resulting in low quality. 12 is light compression that is virtually indistinguishable from the original, the highest possible quality, which of course, results in the largest file size. The maximum quality 12 is recommended for print. For web images, 5 to 8 is an acceptable range.

JPG and PNG

Rename for web — detects characters in the file name that require URL encoding, replaces them with a dash, and converts the file name to lowercase. Prevents URLs that look like “…/This%20is%20the%20File%20Name.jpg”. Instead the result is “…/this-is-the-file-name.jpg”.

PNG

PNG-8/PNG-24 — the choice of bit depth. PNG-8 is indexed color, (8 bits per pixel, of a single channel), whereas PNG-24 is RGB color (24 bits per pixel, or 8 bits per channel, of 3 channels). PNG-8 produces smaller files but at the cost of color precision. The user is the judge of that trade-off and which bit depth is appropriate for the project.

Section 3: Output

Alongside input files, in folders specified above — each format selected to output is saved in the specified folder, which is created in the input folder and in all subfolders if the option is enabled.

Other — select a folder and files are output to the location instead of alongside input files. If Include subfolders is enabled, all are created in the output location.

Whether output is saved alongside input files or in another folder, output files are always saved in each format’s specified Save in folder, which are required and created if needed, including within subfolders. This is necessary to avoid duplicate file name conflicts. If less complex folder structure is desired, use other tools or manually arrange input files in a flat structure before processing.

Replace existing output files — when enabled, existing output files are replaced without user intervention. When disabled, for each existing output file the user is prompted to confirm replacement, skip saving the file, replace all (equivalent to enabling this option), or cancel processing.

Section 4: Settings

The current options may be saved and restored later. Select from the Load drop-down list to choose saved settings, which then updates the current options. Click the Delete button and the saved settings selected in the Load drop-down list are permanently removed. Click the Save button, provide a name for the settings, and the current options are preserved. If the name already exists, the user may choose to replace the saved settings.

The script provides default saved settings named [Default]. These settings cannot be deleted but may be updated to any desired values by saving settings and providing the name [Default], which then overwrites the default settings.

Each time processing begins, the current options are preserved, and the next time the script is launched, options are restored to the last values used.

Further reading

If you’ve reached this point, you know enough to use the script. The remainder is not crucial to read, but helps understand how the script works. This section is last, in the interest of minimizing “Too Long; Didn’t Read.”

Image modes and how each is processed

Of the formats Photoshop can open, the script recognizes aspects of the image and acts intelligently based on the output format. Depending on the combination of factors, images are either processed without issue, or a warning is reported in the log file when particular situations are encountered.

Bitmap — PSD and TIF support bitmap mode, but if asked to Convert to profile, the request is not supported. In this case, the image is converted to grayscale and then to the selected color profile. If Convert to profile is not enabled, bitmap images remain bitmap in PSD and TIF. JPG does not support bitmap mode, and though technically PNG does, saving bitmaps as PNG makes little sense as the format’s intent is for web graphics. JPG and PNG bitmaps are converted to grayscale, then if enabled, to the selected color profile.

Duotone — PSD is the only format (of those the script provides) that supports duotone mode. If Convert to profile is enabled, the image is converted to RGB and then to the selected color profile, otherwise remains duotone mode. TIF, JPG, and PNG do not support duotone mode, so always convert to RGB, then if enabled, to the selected color profile.

Indexed color — PSD, TIF, and PNG-8 support indexed colored and unless converted retain the original color space. JPG and PNG-24 formats do not support indexed color and convert to RGB, then if enabled, to the selected color profile.

Spot color channels — PSD and TIF are the only formats (of those the script provides) that support spot channels. For these formats, whether or not Convert to profile is enabled, spot channels are ignored and remain as-is. JPG and PNG convert to RGB and then merge spot channels to replicate the appearance of the image with the spot colors. Then, if enabled, color is converted to the selected profile.

Multichannel — PSD is the only format (of those the script provides) that support multichannel mode. Because converting multichannel to other color spaces is unreliable, the script does not attempt to do so. Therefore, there is never a change in mode. Multichannel images remain as-is. TIF, JPG, and PNG do not support multichannel mode, and because converting to other color spaces is unreliable, these formats are not saved. A warning to that effect is reported in the log file. It is recommended to work with multichannel images directly in Photoshop rather than use automated tools such as this script.

16 and 32 bits per channel — PSD and TIF support more than 8 bits per channel and will retain values higher than 8 unless Convert to profile is enabled, in which case the image is converted to 8 bits per channel and then to the selected color profile. In all cases, whether converting color or not, JPG and PNG are converted to 8 bits per channel. For the choice PNG-8, the image is further reduced to single channel 8-bit indexed color. 32 bits per channel is not entirely compatible with color management and may result in undesired color shifts, whether converting color or not. It is recommended to work with 32-bit images directly in Photoshop rather than use automated tools such as this script.

TIF compression

The script outputs all TIF images with LZW compression and ZIP layer compression (if layers are preserved).

JPG

When saved, format option used is Baseline Standard for maximum compatibility.

Embedded color profiles

JPG is the only format with the option Embed color profile. PSD and TIF always embed the profile (if applicable, based on mode and whether a profile is assigned), and PNG never embeds a profile.

PNG color space

The script outputs all PNG images in untagged sRGB color space.

Duplicate file names

To protect against duplicate file names overwriting one another, files are output to specified folders. However, because output files are the file’s base name (name without extension) plus the output format extension added, there remains one situation in which duplicate file names could occur — when input files of different extensions, in the same folder, have the same base name. When this circumstance exists, the base name retains the input file extension, which is normally replaced by the output format extension. Any output file with two extensions (because the input extension is retained) is not a glitch; it is named this way to prevent duplicate names overwriting each other.

Available color profiles

For the option Convert to profile, the list of profiles from which to choose is compiled by searching known locations in the system for .icc/.icm files and extracting the profile name. This occurs each time the script is launched. The list should include most of the same profiles Photoshop displays in dialogs such as Color Settings, but it doesn’t match exactly. If a needed profile does not appear in the list, add the profile to a location both Photoshop and the script look for profiles (below) and relaunch the script.

macOS

:Library:ColorSync:Profiles

Windows

\Windows\System32\spool\drivers\color

Download
Batch Multi Save

License details included in download

For help installing scripts, see How to Install and Use Scripts in Adobe Creative Cloud Applications.

IMPORTANT: by downloading the script you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.

CHANGE LOG

Version 2.0.1 (190624)

  1. Miscellaneous.

Version 2.0 (190510)

  1. Revise logging.
  2. Custom alert/notify window.
  3. Restore altered app preferences on completion.
  4. Add option keep paths by name.
  5. Add option keep first path.
  6. Add option save vector masks as path and keep all.
  7. Repair flaws in handling shape layers and vector masks.
  8. Discarding paths no longer disables layers as-is.
  9. Miscellaneous.

Version 19.4.3 (1.7)

  1. Fix disabled layer mask being applied.
  2. Recognize and properly handle vector masks.

Version 19.3.8 (1.6.4)

  1. Add license.

Version 19.2.24 (1.6.3)

  1. Update settings file error handling.
  2. Miscellaneous.

Version 19.2.21 (1.6.2)

  1. Max pixels scale both width and height (prior width only).
  2. Miscellaneous.

Version 19.1.5 (1.6.1)

  1. Fix logging error, full name of unsaved file undefined.
  2. Miscellaneous.

Version 18.12.10 (1.6)

  1. Move log.write() outside process loop.
  2. Progress message and increment to outermost loop.
  3. Update open error message.
  4. Optimize building profile list.
  5. Revise settings object.
  6. Revise log object.
  7. Miscellaneous.

Version 18.12.6 (1.5)

  1. Hard code gray profiles Dot Gains and Gammas.
  2. Remove guides except when layers as-is.
  3. Handle 16- and 32-bit images.
  4. 8 bits per color if convert to profile.
  5. JPG always 8 bits per color (24-bit RGB).
  6. PNG always 8 bits per color (24-bit RGB) before save as 8 or 24.
  7. Test for duplicate baseName, add back extension.
  8. Reorder transformations: layers, color, ppi, max pixels, then paths.
  9. Disable layers as-is if resample, limit pixels, or alter paths.
  10. UI alignment adjustments.

Version 18.12.1 (1.4)

  1. Handle odd formats, bitmap, duotone, spot colors, multichannel.
  2. PNG use Save For Web, add options PNG-8 / PNG-24.

Version 18.11.29 (1.3)

  1. Revise vector options, rename PDF/AI/EPS options.
  2. Add to vector options choice for PDF images.
  3. Rename for web include replacing underscore.
  4. Save as PNG omit profile.

Version 18.11.27 (1.2)

  1. Revise getFiles() function for hidden files/other refinements.
  2. Add vector options to process AI, PDF, and vector EPS.
  3. Miscellaneous.

Version 18.11.23 (1.1)

  1. Add keep paths, only clipping, or discard all.
  2. Ignore some extensions we know Photoshop won't open.

Version 18.11.21 (1.0)

  1. Initial release.