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

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

168

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 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?

 

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
Guide ,
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)

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 ,
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.

 

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

Copy link to clipboard

Copied

LATEST

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

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