Skip to main content
Known Participant
July 17, 2009
Answered

adding suffix to file name and re-saving

  • July 17, 2009
  • 1 reply
  • 3945 views

I need a simple script that saves the open file as a jpeg at 80% compression to the same directory as the original, while adding a suffix to the end of the file name.  So for instance, if the file open is "image.png", I'd like it saved as "image_thumb.jpg".  I've tried to create my own, but I just don't have the chops for scripting.  Can anyone help?

This topic has been closed for replies.
Correct answer Michael_L_Hale

Ah, works great!  I'm sure you can see now how little experience I have with scripting.  I've marked this answered, but what would I have to change to have the file saved to the same folder as the original?

I found this, but I'm not sure how to use it.


Replace the line

var docPath =Folder("~/Desktop");

with

var docPath = decodeURI(activeDocument.path);

1 reply

Inspiring
July 17, 2009

This would be a good start:

http://ps-scripts.com/bb/viewtopic.php?t=2772

Known Participant
July 20, 2009

Thanks xbytor2, but unfortunately I'm still having problems with it. I amended the script to set the "docPath" just to "~/Desktop" instead of "~/Desktop/cropped" and I then I get the following script alert:

Unknown filetype please use manual save.

Not exactly sure why it's doing that.  Any help would be appreciated.

Inspiring
July 21, 2009

Hm, it almost gets through it, but hangs on the last line.  The error states:


Error 1224: Numeric value expected

Line: 23

-> activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);


In the JPEGSaveOptions you need to set the quality to a value between 1 and 12