Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Save as Dialog Script

Contributor ,
Mar 31, 2025 Mar 31, 2025

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

 

TOPICS
Actions and scripting
181
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 31, 2025 Mar 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.put
...
Translate
Adobe
Community Expert ,
Mar 31, 2025 Mar 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);
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 31, 2025 Mar 31, 2025

This Works Great! :heart_suit:

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

 

Thank you very much for your help!!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2025 Mar 31, 2025

@Innotex Nico Tanne 

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 31, 2025 Mar 31, 2025

Hello Stephen,

 

The path in this code is taken from the output file, I have built a small ui and save the path after saving and use it immediately for the subsequent save operations. The only thing that doesn't work is that the saved data appears in the last used list of Photoshop only if I save via Photoshop itself 😞 

 

I have also noticed that if I save too many files via the script, Photoshop crashes at some point. For example, after 50 saves.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 01, 2025 Apr 01, 2025
LATEST

Ah, that makes sense, I was wondering where/how you were doing that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines