ExtendScript not saving PSD to specified path

Explorer ,
Aug 26, 2022 Aug 26, 2022

Copy link to clipboard

Copied

I have this code:

 

if (!app.activeDocument.saved) {
    var options = new PhotoshopSaveOptions()
    var path = new File("C:/Maps to upload.psd")
    app.activeDocument.saveAs(path, options)
  }

alert(app.activeDocument.path)
 
However, it does not save in the specified path, rather it saves in the following directory:
 
TheAzzam_0-1661510186191.png

 

 
TOPICS
Actions and scripting , SDK , Windows

Views

58

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 Expert ,
Aug 26, 2022 Aug 26, 2022

Copy link to clipboard

Copied

@TheAzzam 

 

I rarely script for solely for Windows OS, most of my work is cross-platform, so I'm not sure if the following will help or not...

 

var path = new File("\\C\\Maps to upload.psd")

// or

var path = new File("/C/Maps to upload.psd")

 

Perhaps script writing directly to C:\ is not permitted by Photoshop or scripting?

 

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 Expert ,
Aug 26, 2022 Aug 26, 2022

Copy link to clipboard

Copied

 

 

When you use the name path for a variable, you are referencing the read-only property app.path,

2022-08-26_13-48-22.png

so:

if (!app.activeDocument.saved) {
    var options = new PhotoshopSaveOptions()
    var pth = new File("c:/Maps to upload.psd")
    app.activeDocument.saveAs(pth, options)
  }

alert(app.activeDocument.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
Community Expert ,
Aug 26, 2022 Aug 26, 2022

Copy link to clipboard

Copied

 

@jazz-y – good catch!

 

Thus the preference for variable names such as myPath or thePath or docPath etc to play it safe if one can't remember the reserved names... or even Path as this is case sensitive.

 

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 Expert ,
Aug 26, 2022 Aug 26, 2022

Copy link to clipboard

Copied

LATEST

That's right, I've fallen for this trap more than once 😉

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