Skip to main content
Inspiring
January 18, 2019
Answered

Javascript for "Save As" dialog prompt in photshop

  • January 18, 2019
  • 1 reply
  • 4847 views

Hello, and thanks to all who reply,

  Im trying to simply figure out how to trigger a "save as" dialog prompt in javascript. I just want to the current active document to pop a save as dialog which the user can then choose where to save. Thanks you.

This topic has been closed for replies.
Correct answer Kukurykus

So I'd like to save as a .psb to a specific folder on the desktop with NO save dialog. This is what I have so far. It isn't working though. I can see in the designated folder it starts to write a psd (not psb) but then it disappears from the folder and nothing else happens.

function dM(v) { 
   displayDialogs = eval('DialogModes.' + (v ? 'ALL' : 'NO')) 

 
for(aD = activeDocument, i = 0; i < 2; i++) { 
   dM(i); if (i) File(aD.fullName).remove() 
   pth = '~/desktop/DO_NOT_TOUCH_FOR_SCRIPTING/ALL_VERSIONS' 
   aD.saveAs(File(pth)); if (i) dM(!i)
}


I understand that 'DO_NOT_TOUCH_FOR_SCRIPTING' folder on desktop is already created? If so, and you want to save a file without dialog popping up, then use following code:

displayDialogs = DialogModes.NO, sTT = stringIDToTypeID

dsc1 = new ActionDescriptor(), dsc2 = new ActionDescriptor()

fle = File('~/desktop/DO_NOT_TOUCH_FOR_SCRIPTING/ALL_VERSIONS.psb')

dsc2.putBoolean(sTT('maximizeCompatibility'), true)

dsc1.putObject(sTT('as'), sTT('largeDocumentFormat'), dsc2)

dsc1.putPath(sTT('in'), fle), executeAction(sTT('save'), dsc1)

1 reply

Kukurykus
Legend
January 18, 2019

displayDialogs = DialogModes.ALL, activeDocument.save(), displayDialogs = DialogModes.NO

Inspiring
January 18, 2019

Hey thats great, thank you. I thought it should be a simple line of code. If I wanted to pre-dtermine the name when saving, how would i doo that? Ex. I want the file to be named "ALL_VERSIONS"

Kukurykus
Legend
January 18, 2019

You're a beast! Works! Thank you so much my man!


Mark as correct answer then