Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


app.activeDocument.saveAs not working in Photoshop v.23.0.0

Community Beginner ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

I have a script that I'm using in a action to save the current file in a specific Folder.

It worked fine until I upgraded my phothoshop version.

 

This is the current error that I'm getting:

This functionality might not be available in this version of Photoshop.

 

Photoshop Version 23.0.0

 

Screen Shot 2021-11-15 at 9.52.50 PM.png

 

 

This is the Script:

var JPGquality = 12;
var suffix='_03';
var docPath = app.activeDocument.path;
var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var suffix = '_0';
var tries = 0;
var saveFile = new File(docPath + '/Exported/' + docName + suffix + tries + '.jpg');
var fileExists = saveFile.exists;

tries++;

while (fileExists) {
  saveFile = new File(docPath + '/Exported/' + docName + suffix + tries + '.jpg');
  tries++;
  fileExists = saveFile.exists;
}

SaveJPEG(saveFile, JPGquality);

function SaveJPEG(saveFile, jpegQuality) {
  jpgSaveOptions = new JPEGSaveOptions();
  jpgSaveOptions.embedColorProfile = true;
  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
  jpgSaveOptions.matte = MatteType.NONE;
  jpgSaveOptions.quality = JPGquality; //1-12
  activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
}

 

 

It fails in the last line while trying to invoce saveAs

I also tried with app.activeDocument.saveAs(........)

TOPICS
Actions and scripting, macOS

Views

101

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 2 Correct answers

Adobe Community Professional , Nov 15, 2021 Nov 15, 2021
I see no problems; have you made sure the Folder exists and the file’s name contains no illegal character? 

Likes

Translate

Translate
Adobe Community Professional , Nov 16, 2021 Nov 16, 2021
Do you have 'Exported' subfolder in the folder your file was open from?

Likes

Translate

Translate
Adobe Community Professional ,
Nov 15, 2021 Nov 15, 2021

Copy link to clipboard

Copied

I see no problems; have you made sure the Folder exists and the file’s name contains no illegal character? 

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 Beginner ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

Folder exists, but you bring a good point it might not be in the right path 

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
Adobe Community Professional ,
Nov 16, 2021 Nov 16, 2021

Copy link to clipboard

Copied

Do you have 'Exported' subfolder in the folder your file was open from?

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 Beginner ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

ohhhh you hit the nail in the head!

The Folder is actually outside of the docPath.  (/../Exported)

 

Thanks a lot for brining this knowlege forward!

 

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
Adobe Community Professional ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

Does your script work now?

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 Beginner ,
Nov 24, 2021 Nov 24, 2021

Copy link to clipboard

Copied

Yes it does thanks! the issue was the docPath location.



--

*Hector Rodriguez*
*Email: *hector.rodriguez@gmail.com | *Mobile:* +1.416.9392673

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
Adobe Community Professional ,
Nov 28, 2021 Nov 28, 2021

Copy link to clipboard

Copied

LATEST

@HecOsbRod  I thought that the following addition may help, where I have added a check to create the export folder if it does not currently exist in the save path. This should automatically avoid the issue.

 

var JPGquality = 12;
var suffix='_03';
var docPath = app.activeDocument.path;
var outputFolder = new Folder(decodeURI(docPath) + '/' + 'Exported');
var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var suffix = '_0';
var tries = 0;
var saveFile = new File(outputFolder + '/' + docName + suffix + tries + '.jpg');
var fileExists = saveFile.exists;

if (outputFolder.exists === false) outputFolder.create();

tries++;

while (fileExists) {
  saveFile = new File(outputFolder + '/' + docName + suffix + tries + '.jpg');
  tries++;
  fileExists = saveFile.exists;
}

SaveJPEG(saveFile, JPGquality);

function SaveJPEG(saveFile, JPGquality) {
  jpgSaveOptions = new JPEGSaveOptions();
  jpgSaveOptions.embedColorProfile = true;
  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
  jpgSaveOptions.matte = MatteType.NONE;
  jpgSaveOptions.quality = JPGquality; //1-12
  activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
}

 

 

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