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

Possible bug in Photoshop CS6 with app.activeDocument.path.

Guest
Oct 12, 2012 Oct 12, 2012

Copy link to clipboard

Copied

JavaScript running in Photoshop CS6 under OS X 10.7.5 returns the wrong result for app.activeDocument.path when the file is located on the boot drive. The result is undefined and an error message incorrectly states that the document has not been saved yet. If the file is located on a remote volume, the correct path is returned.

To reproduce this problem, create a new file in Photoshop CS6 on a Mac. Save the file to the desktop. With the file still open, run the following script in ExtendScript Toolkit.

// start script

var thePath = app.activeDocument.path;

alert(thePath);

// end script

Running the same script with a file located on a server volume open in Photoshop correctly returns "/path/to/file.psd" instead of undefined and no error occurs.

This appears to be a bug in Photoshop CS6's JavaScript implementation. This problem did not exist in Photoshop CS3.

A similar issue prevents Photoshop CS6 from saving files to the boot drive using activeDocument.saveAs.

Has anyone else experienced this problem? If so, have you discovered an alternate method to determine the file path or save a file on the boot drive?

TOPICS
Actions and scripting

Views

3.7K

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
Adobe Employee ,
Oct 12, 2012 Oct 12, 2012

Copy link to clipboard

Copied

Hi,

What is the name of your boot drive?

regards,

steve

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
Guest
Oct 12, 2012 Oct 12, 2012

Copy link to clipboard

Copied

Odysseus.

I have also experienced the same problem with another machine.

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
New Here ,
Oct 31, 2012 Oct 31, 2012

Copy link to clipboard

Copied

I am haivng the same issue with Extendscript CS5 and Photoshop CS5. I have not been able to test a remote volume, but I receive the same error on the boot drive. I open a file that is already saved on disk in Photoshop CS5 and then run a script which tries to access the activeDocument.path property. The script breaks on that line and the error message is "The document has not yet been saved". The is clearly an error, because of course the document has been saved, I loaded it from a file on disk (and no changes have been made to it before trying to access the path property)!

Were you able to find a solution or a workaround?

Thanks!

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
Guru ,
Oct 31, 2012 Oct 31, 2012

Copy link to clipboard

Copied

Don't know if this will help much but at least you can use it to check a document's filepath without throwing an error. And maybe tell if the problem is with the Photoshop DOM.

function hasFilePath(){// returns true/false

    var ref = new ActionReference();

    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

    return executeActionGet(ref).hasKey(stringIDToTypeID('fileReference'));

};

function getFilePath(){// returns path as a string if exists, undefined if not

    var ref = new ActionReference();

    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

    var desc = executeActionGet(ref);

    if(desc.hasKey(stringIDToTypeID('fileReference'))) return decodeURI(desc.getPath(stringIDToTypeID('fileReference')));

};

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
New Here ,
Oct 31, 2012 Oct 31, 2012

Copy link to clipboard

Copied

Thanks Michael! Those functions look quite useful. I was using the path property as a place to save out PNGs from the PSD in the same location as the PSD, but because the path property was not working, I chose to hardcode a location where to save the files.

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
Guest
Nov 02, 2012 Nov 02, 2012

Copy link to clipboard

Copied

Thank you. This does give me the document's filepath. Unfortunately, there is still clearly a bug somewhere that prevents the use of activeDocument.path.

I resolved the issue with activeDocument.saveAs by specifying the full path of the save location using:

/Volumes/Users/chip/Documents/...

instead of:

/Users/chip/Documents/...

The latter format did work in JavaScript with Photoshop CS3, as well as every other scripting language I know of that uses POSIX-style paths.

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
Explorer ,
Jan 12, 2016 Jan 12, 2016

Copy link to clipboard

Copied

LATEST

You can get the full path like this:

#target photoshop

var thePath = app.activeDocument.fullName;

alert(thePath);

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