Skip to main content
Inspiring
January 18, 2019
Answered

Javascript for "Save As" dialog prompt in photshop

  • January 18, 2019
  • 1 reply
  • 4848 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

Innotex Nico Tanne
Inspiring
March 23, 2023

Hi Kukurykus,

I have a problem with this code line since update to Photoshop 24.3

i tryed so much but i never get the Save as dialog.

Maybe it is a bug or they have have changed the Code?

Can you help me to get the save as dialog via script again?

 

Best Regards Nico

Innotex Nico Tanne
Inspiring
March 23, 2023

I meant this code:

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