Photoshop: CS5 Javascript, saveAs() gets wrong directory.

  • 1
  • Problem
  • Updated 5 years ago
  • (Edited)
Using the following javascript (extendscript):

saveOptions = new PNGSaveOptions();
saveOptions.interlaced = false;
alert("Saving: " + sourceImage.path + "/" + sourceImage.name +
"\n in: " + targetFolder.toString() + " as a " + saveOptions.toString());
sourceImage.saveAs(targetFolder, saveOptions, false, Extension.LOWERCASE);

I get a system "Save as" dialog that points to the first directory I save a file to in that script, even though the alert box shows that the target folder is the desired folder.
Photo of Kevin Hollingshead

Kevin Hollingshead

  • 3 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14046 Posts
  • 1735 Reply Likes
What is targetFolder? Is it a valid folder?
Photo of Kevin Hollingshead

Kevin Hollingshead

  • 3 Posts
  • 0 Reply Likes
Yes. This is a script that I developed on my Mac running PS CS6 (creative cloud), but is being used by a colleague on a PC running PS CS5. It works fine on my Mac in extensive testing. Is there somewhere I could post the entire script?
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14046 Posts
  • 1735 Reply Likes
You could post it here, or put on Dropbox, or other sharing site.
Photo of Kevin Hollingshead

Kevin Hollingshead

  • 3 Posts
  • 0 Reply Likes
Weird, I thought dropbox had a public folder? Here's a link, can you access the file?

https://www.dropbox.com/s/okwp3ds7z0g...