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

saveAs() function causes disk error when called from javascript in Photoshop 25.3

Community Beginner ,
Jan 10, 2024 Jan 10, 2024

Copy link to clipboard

Copied

Although the following script worked previous, it appears to fail now with a disk error (-43).

Anyone else see this?  Any fixes or workarounds?

 

// Define the file path where you want to save the file
var filePath = "C:/Users/<myusername>/Desktop/file.jpg";

// Create a new File object with the file path
var jpgFile = new File(filePath);

// Define the JPEG save options
var jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;

// Save the active document with the defined file and JPEG save options
app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);

 

TOPICS
Actions and scripting

Views

207

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 , Jan 11, 2024 Jan 11, 2024

Ok, I found your issue. you are defining your file path with the file name in it. Try this:

 

 

 

// Define the file path where you want to save the file
var filePath = new Folder("~/Desktop/");

// Create a new File object with the file path
var jpgFile = new File(filePath + '/jpgFile.jpg');

// Define the JPEG save options
var jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = Ma
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

I am a Mac-user myself, but as the Script seems otherwise fine I suspect there might be an issue with the Path. 

Did you replace »<myusername>« with your username? 

Does a File of that name and location already exist? 

Is enough space available? 

 

Could you please post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible? 

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 ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

I would change the line declaring the file path to using the "~". This will make it so that that line works on Win and Mac, and any user that uses that computer.

var filePath = "/~/Desktop/file.jpg";

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 ,
Jan 11, 2024 Jan 11, 2024

Copy link to clipboard

Copied

LATEST

Ok, I found your issue. you are defining your file path with the file name in it. Try this:

 

 

 

// Define the file path where you want to save the file
var filePath = new Folder("~/Desktop/");

// Create a new File object with the file path
var jpgFile = new File(filePath + '/jpgFile.jpg');

// Define the JPEG save options
var jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;

// Save the active document with the defined file and JPEG save options
app.activeDocument.saveAs(jpgFile, jpgSaveOptions, 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