Skip to main content
Inspiring
November 24, 2024
Open for Voting

Saving JPEGs Via an Action

  • November 24, 2024
  • 23 replies
  • 1321 views

I have an action that saves JPEG files. Basically, it changes to 8-bit mode, does a Save A Copy, choose file type JPEG and Saves the file. The first issue is that in PS 26.1, the folder to save to is always the same folder as that used when the action was created. I believe previously in earlier PS versions, it always brought up the most recently saved folder. If I am working in a specific folder, adjust an image as desired, save a PSD file, and then subsequently click my action to Save As JPEG, the folder where JPEG will be saved is always the same, which is very annoying because have to navigate to the current folder. You can imaging if I have multiple images to edit, this is bothersome because it takes extra time. This could be a bug that did not occur in 26.0 or previous versions. Secondly, I've asked for this before, but please change the code to always save to the same folder where the saved PSD file is located. I don't want to navigate to a different folder ever when saving a JPEG file, in an action, after having opened or saved the image to a PSD file. Navigating is unnecessary if the code were revised to do as I requested.

23 replies

Inspiring
November 27, 2024

Stephan_A, I have never used a script before in Adobe. I taught myself Javascript after retiring in 2008 so I could create custom websites, but have not used Javascript for many years now. Nevertheless, I was able to understand your script and will give it a try. I have to figure out how to install it into PS. The document you referenced below your script will be my guide. I will need a few days until I can get to it because of the holidays. Thank you for taking the time to write it. Ken

Stephen Marsh
Community Expert
Community Expert
November 27, 2024
quote

The first figure shows the action expanded. The red arrow points to the "In" parameter, which I interpret to mean "Save the file INthis folder." The "In" parameter value is always the same whenever I run the action. That value was recorded when I recorded the action. What I really want is for the "In" value to be the folder where the .PSD file is located. The second figure shows my PS preferences. Notice that the "Save As to Original Folder" is checked. BTW, checking the Enable legacy Save As has the same problem.

 

 

The "Save As to Original Folder" is only for manual saves, not for recorded actions, where the path from the local computer recording the action is always used.

 

quote

I should not have to write a script. It should just work. It always did before Photoshop changed the requirement to save JPEGs using the Save As Copy a few versions previous. The Photoshop developers should be able to examine the preference of saving to the original folder and use that value for the "In" parameter, if they even need an "In" parameter.


By @Ken Curtis

 

 

I tested in v2019 which pre-dates the "Legacy Save As" and nothing has changed. Actions have always recorded the "in" local absolute path and they always use that when run, except for File > Automate > Batch which offers the ability to override the recorded action save command.

 

I understand what you want, which is why I offered a script. Scripts offer more possibilities than actions. I agree that actions should offer more refined and flexible features.

 

I have voted on your idea (feature request).

Inspiring
November 26, 2024

Thanks Bojan. I always leave the file name in the Save dialog. If the .PSD file were named MyImage.psd then the JPEG file should be named MyImage.jpg. Untitled is certainly not what I want to do, because then I would need to manually rename it as I really want it to be.

Inspiring
November 26, 2024

Thank you Stephan_A_. Let me try to clarify what I am trying to do in hopes that this explanation will be clearer. I work on an image in 16 bits and save it as a .PSD file. Nothing magic there and it works fine. Next I want to save the same image as JPEG file so that both the .PSD and .JPG files are in the same folder. I wrote an action to change the mode to 8 bits, save the file as a JPEG (this is the problem part) and then return to my previous step.

 

 

The first figure shows the action expanded. The red arrow points to the "In" parameter, which I interpret to mean "Save the file IN this folder." The "In" parameter value is always the same whenever I run the action. That value was recorded when I recorded the action. What I really want is for the "In" value to be the folder where the .PSD file is located. The second figure shows my PS preferences. Notice that the "Save As to Original Folder" is checked. BTW, checking the Enable legacy Save As has the same problem.

 

 

I should not have to write a script. It should just work. It always did before Photoshop changed the requirement to save JPEGs using the Save As Copy a few versions previous. The Photoshop developers should be able to examine the preference of saving to the original folder and use that value for the "In" parameter, if they even need an "In" parameter.

 

I hope this helps.

Bojan Živković11378569
Community Expert
Community Expert
November 26, 2024

"I also had to leave the filename because without it, the saving has no idea what to name the file and does nothing."

 

Have you tested it, or is that just your opinion? Or do you misunderstand? Do not delete the file name when recording; just leave it as is. It will use the file name to save the file; it can be saved as "untitled" if you created the file without naming it. Please test it.

Stephen Marsh
Community Expert
Community Expert
November 26, 2024
quote

I am beginning to think that when I click on Save a Copy while recording an action, Photoshop should omit the "In" paramter. Perahaps that would solve the problem. Adobe should automatically populate the folder in the Save dialog with the same folder where the .PSD file is located. Just a thought. Adobe, kindly ask your software developers to try this.


By @Ken Curtis

 

 

As @D Fosse wrote, the alternative is a script to perform the save action to the same folder as the open file. Perhaps something like this:

 

/*
JPEG Save As a Copy to Source Directory.jsx
Stephen Marsh
v1.0 - 26th November 2024
https://community.adobe.com/t5/photoshop-ecosystem-ideas/saving-jpegs-via-an-action/idc-p/15002989
*/

#target photoshop

if (app.documents.length) {

    // Check if the bit depth is 32 bpc
    if (app.activeDocument.bitsPerChannel == BitsPerChannelType.THIRTYTWO) {
        throw alert("Script cancelled!\rThe image mode is 32 bpc, tone mapping to 8 or 16 bpc is required before continuing.");
    }

    var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');

    try {
        // Use the previously saved path
        var docPath = app.activeDocument.path;
    } catch (e) {
        // If unsaved, prompt for save directory
        var docPath = new Folder.selectDialog("Unsaved base file, select the output folder:");
    }

    // File Path & Naming
    var nameAndPath = new File(docPath + '/' + docName + '.jpg');

    if (nameAndPath.exists) {
        // true = 'No' as default active button
        if (!confirm("File exists, overwrite: Yes or No?", true))
            // throw alert("Script cancelled!");
            throw null;
    }

    saveJPEG(nameAndPath);

} else {
    alert("You must have a document open!");
}

function saveJPEG(saveDetails) {
    var jpgSaveOptions = new JPEGSaveOptions();
    jpgSaveOptions.embedColorProfile = true;
    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgSaveOptions.matte = MatteType.NONE;
    jpgSaveOptions.quality = 10;
    app.activeDocument.saveAs(saveDetails, jpgSaveOptions, true, Extension.LOWERCASE); // true for save a copy
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Stephen Marsh
Community Expert
Community Expert
November 26, 2024
quote

Stephen_A thank you for your suggestion. I am not sure what you are talking about.


By @Ken Curtis

 

Actions either record the full local path, or the full local path + filename of open doc when recording.

 

 

Modal control for interactive playback:

 

Inspiring
November 26, 2024

I am beginning to think that when I click on Save a Copy while recording an action, Photoshop should omit the "In" paramter. Perahaps that would solve the problem. Adobe should automatically populate the folder in the Save dialog with the same folder where the .PSD file is located. Just a thought. Adobe, kindly ask your software developers to try this.

Inspiring
November 25, 2024

Stephen_A thank you for your suggestion. I am not sure what you are talking about. When the action is recorded, I click on the menu item Save As. I do have a ??? set to be interactive during the saving step so that I can select different folders and change file names. The issue is my having to select the save to folder each time I run the action, which is a pain. If Photoshop could some how populate the Save As dialog with the original folder where the .PSD file is located, it would save a ton of work.

Inspiring
November 25, 2024

D Fosse, thank you for the suggestion, but that did not work. First I had to use Save As instead of Save because otherwise it would save a .PSD file. In Save As, I select type JPEG from the dropdown. I also had to leave the filename because without it, the saving has no idea what to name the file and does nothing. I did clear out the folder information before saving. When I finished the new action, I looked at the sub-action labeled Save. One of the line items is "In" and it recorded the folder where the JPEG was saved. Unfortunately, when I go to another directory, launch a different .PSD file and then try to execute the action, the "In" remains as it was when the action was recorded.