Skip to main content
Innotex Nico Tanne
Inspiring
March 31, 2025
Answered

Save as Dialog Script

  • March 31, 2025
  • 1 reply
  • 471 views

Hello everyone,

 

I need a little help 😅

 

I want to open the Save As dialog via Extendscript with the default settings TIFF and LZW.

Unfortunately, I always have the problem that Photoshop does not remember the new path and when I save the file again later, the file ends up in the old path.?

In addition, it would be nice if the dialog always opened in the last path in which I saved. so actually like when I use the normal Save As dialog from Photoshop.

 

I hope I was able to explain this clearly and you can help me?

 

Many thanks in advance

 

Correct answer Stephen Marsh

@Innotex Nico Tanne 

 

You can try something like this for an interactive LZW TIFF save:

 

try {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
	try {
		var docPath = app.activeDocument.path;
	} catch (e) {
		var docPath = "~/Desktop/";
	}
	descriptor2.putEnumerated(s2t("byteOrder"), s2t("platform"), s2t("IBMPC"));
	descriptor2.putBoolean(s2t("LZWCompression"), true);
	descriptor2.putBoolean(s2t("saveTransparency"), true);
	descriptor2.putEnumerated(s2t("layerCompression"), s2t("encoding"), s2t("zip"));
	descriptor.putObject(s2t("as"), s2t("TIFF"), descriptor2);
	descriptor.putPath(s2t("in"), new File(docPath + "/" + docName + ".tif"));
	descriptor.putBoolean(s2t("lowerCase"), true);
	descriptor.putEnumerated(s2t("saveStage"), s2t("saveStageType"), s2t("saveBegin"));
	executeAction(s2t("save"), descriptor, DialogModes.ALL);
} catch (e) {
	alert("Error: " + e + " Line: " + e.line);
}

1 reply

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
March 31, 2025

@Innotex Nico Tanne 

 

You can try something like this for an interactive LZW TIFF save:

 

try {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
	try {
		var docPath = app.activeDocument.path;
	} catch (e) {
		var docPath = "~/Desktop/";
	}
	descriptor2.putEnumerated(s2t("byteOrder"), s2t("platform"), s2t("IBMPC"));
	descriptor2.putBoolean(s2t("LZWCompression"), true);
	descriptor2.putBoolean(s2t("saveTransparency"), true);
	descriptor2.putEnumerated(s2t("layerCompression"), s2t("encoding"), s2t("zip"));
	descriptor.putObject(s2t("as"), s2t("TIFF"), descriptor2);
	descriptor.putPath(s2t("in"), new File(docPath + "/" + docName + ".tif"));
	descriptor.putBoolean(s2t("lowerCase"), true);
	descriptor.putEnumerated(s2t("saveStage"), s2t("saveStageType"), s2t("saveBegin"));
	executeAction(s2t("save"), descriptor, DialogModes.ALL);
} catch (e) {
	alert("Error: " + e + " Line: " + e.line);
}
Innotex Nico Tanne
Inspiring
April 1, 2025

This Works Great!

I saved the previous path in a variable and all worked as i want 👍

 

Thank you very much for your help!!!!

Stephen Marsh
Community Expert
Community Expert
April 1, 2025

@Innotex Nico Tanne 

 

You're welcome! How is the previous path defined or obtained?