Skip to main content
LukasJuskonis
Participant
June 18, 2018
Answered

A script to save the file in the same location

  • June 18, 2018
  • 1 reply
  • 3459 views

Hello guys,

I have a problem with using droplets to save the different format of the file to the same location.

Could someone help me with creating a script that would do the following:

1. Open the doc
2. Save it as tiff (Image compression : ZIP, Pixel order : Interleaved, Byte order : Macintosh, without layers) to the same location where the main file is.
3. Save it as jpg (Quality 7) to the same location where the main file is.
4. Close the doc

This topic has been closed for replies.
Correct answer Kukurykus

Thank you very much !

I think a logical sequence for everything to work would be:

1. Dragging .psd files on Droplet

2. It opens the files and activates a script.

Script order should be:

1. Save a jpg (Quality 7) to the same file location where currently opened .psd is.

2. Image - mode - CMYK colors (Converting colors from rgb to cmyk)

3. Save a tiff (Without layers, Pixel order: Interleaved, Byte order: Macintosh) to the same file location where currently opened .psd is

4. Close the doc


arr = [jpg = new JPEGSaveOptions, tif = new TiffSaveOptions]
jpg.jpegQuality = 7, tif.byteOrder = ByteOrder.MACOS
tif.layers = !(tif.interleaveChannels = true)

for(i = 0; i < arr.length; i++) {
     if (i) aD.changeMode(ChangeMode.CMYK);
     (aD = activeDocument).saveAs(File(String(aD
     .fullName).slice(0, -3) + (i ? 'tif' : 'jpg')), arr)
}

aD.close(SaveOptions.DONOTSAVECHANGES)

Save it to 'Presets / Sctipts' of your Photoshop folder. Then relaunch Ps and create new Action set, then new Action, and from 'dropdown / flyout' menu you click icon in right corner of Actions panel and select 'Insert Menu Item...'. Finally from 'File / Automate' choose 'Create Droplet', and only one you have to do is to choose Droplet path to be saved there. Now each time you drag a .psd file on droplet it will do that you asked. Now you can mark my answer as correct solution

1 reply

Kukurykus
Legend
June 18, 2018

Actually version for those steps before you changed them:

arr = [jpg = new JPEGSaveOptions, psd = new PDFSaveOptions]

open(File(fle = '~/desktop/someFile.psd')), aD = activeDocument

for(i = 0; i < arr.length; i++) {

    aD.saveAs(File(fle.slice(0, -3) + (i ? 'pdf' : 'jpg')), arr, true)

}

aD.close(SaveOptions.DONOTSAVECHANGES)

A version for current request:

arr = [jpg = new JPEGSaveOptions, tif = new TiffSaveOptions]

open(File(fle = '~/desktop/someFile.psd')), aD = activeDocument

tif.layers = tif.interleaveChannels = true, tif.byteOrder = ByteOrder.MACOS

tif.layerCompression = LayerCompression.ZIP, jpg.jpegQuality = 7

for(i = 0; i < arr.length; i++) {

    aD.saveAs(File(fle.slice(0, -3) + (i ? 'tif' : 'jpg')), arr, true)

}

aD.close(SaveOptions.DONOTSAVECHANGES)

In case of this one for tiff format you must decide what you want - either you keep layers and use ZIP compression, or you resign from layers but then can not use ZIP compression. If you want that second option then change 4th and 5th lines to:

tif.layers = !(tif.interleaveChannels = true)

tif.byteOrder = ByteOrder.MACOS, jpg.jpegQuality = 7

LukasJuskonis
Participant
June 19, 2018

Hey, when I'm trying the script I get a problem message :

Kukurykus
Legend
June 19, 2018

I guess you didn't use your own path with your file at the end of but remained that I used? If so you need to at least create a .psd file that you will name someFile and then save it on desktop.