Skip to main content
Inspiring
October 29, 2023
Answered

Recorded action Save as to current folder (instead of a pre-specified folder)?

  • October 29, 2023
  • 3 replies
  • 2757 views

In a recorded action I use a Save as in order to ensure the file is saved with the correct settings. When recording I have been careful to only click on the items I want to be set/adjusted when saving. However, even though I don't click the folder, a specific folder is included in the recorded action. How can I record an action where the file is saved in the current folder, not a pre-specified one? 

 

Correct answer Stephen Marsh

Actions record an absolute, machine/platform specific filename and path.

 

It is possible to only record the absolute file path, without a name if you don't click on or change the name when recording the action:

 

 

You can check the modal control to make the action step interactive, as highlighted below with the red box:

 

 

Otherwise, you would need a script.

 

P.S. There is a hack to record saving the file to a temporary external file path that is then made unavailable (such as a server or removable device), then the path is shown as "file or folder not found" and the action would then default to the current path. Refer to the second last Save step example below:

 

 

3 replies

Stephen Marsh
Community Expert
Community Expert
November 4, 2023

The following script will Save As to the current folder with settings as discussed in this topic:

 

/*
Save As TIFF to Current Folder.jsx
v1.0, 5th November 2023, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/recorded-action-save-as-to-current-folder-instead-of-a-pre-specified-folder/td-p/14194382
*/

#target photoshop

    (function () {

        try {
            activeDocument.path;
            var docPath = activeDocument.path.fsName;
            var docName = activeDocument.name.replace(/\.[^\.]+$/, '');
            var saveFileTIFF = new File(docPath + '/' + docName + '.tif');

            /*
            // Interactive confirmation to overwrite an existing file...
            if (saveFileTIFF.exists) {
                // true = 'No' as default active button
                if (!confirm("The file '" + docName + ".tif' exists, overwrite: Yes or No?", true))
                    return;
            }
            */
            
            // Use true to Save As a Copy, false to Save As
            saveTIFF(saveFileTIFF, false);

        } catch (e) {
            alert("Error!" + "\r" + e + ' ' + e.line);
        }

    }());


function saveTIFF(saveFileTIFF, aCopy) {
    tiffSaveOptions = new TiffSaveOptions();
    tiffSaveOptions.embedColorProfile = true;
    // ByteOrder.MACOS or ByteOrder.IBM
    tiffSaveOptions.byteOrder = ByteOrder.IBM;
    tiffSaveOptions.transparency = true;
    tiffSaveOptions.layers = true;
    tiffSaveOptions.layerCompression = LayerCompression.ZIP;
    tiffSaveOptions.interleaveChannels = true;
    tiffSaveOptions.alphaChannels = true;
    tiffSaveOptions.annotations = true;
    tiffSaveOptions.spotColors = true;
    tiffSaveOptions.saveImagePyramid = false;
    // NONE | JPEG | TIFFLZW | TIFFZIP
    tiffSaveOptions.imageCompression = TIFFEncoding.TIFFZIP;
    activeDocument.saveAs(saveFileTIFF, tiffSaveOptions, aCopy, Extension.LOWERCASE);
}

 

There is /* commented out */ placeholder code to confirm overwriting an existing file (the script will overwrite an existing file without interaction unless the disabled code is enabled).

 

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

 

Inspiring
November 5, 2023

Super, I'll try this tomorrow (I'm in Europe so pretty late her 🙂). It is really super kind of you to make all this effort, I so appreciate it! 🌟🌟🌟🌟🌟

Stephen Marsh
Community Expert
Community Expert
November 2, 2023

@Chris201Chris 

 

So how did the updated action go?

 

Inspiring
November 4, 2023

😂 I'm not having much luck I'm afraid. This action opens up the save as window and "waits"... so it is the same as if I instead of starting the action just press Shift+Ctrl+S...

(I don't know if there are any more methods to try, but if there is, and you are willing to try again, could you please add the alternative "Image compression: zip" as well - I know I did't have it in my original action, but am trying to compress my files when possible)

Stephen Marsh
Community Expert
Community Expert
November 4, 2023

But it DID open to the current image location, yes???  :]

 

I believe that you have now exhausted the possibilities of Actions if you don't wish to have interactivity. 

A script can silently save into the current directory without a dialog.

 

The script save step can be recorded into an Action.

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
October 29, 2023

Actions record an absolute, machine/platform specific filename and path.

 

It is possible to only record the absolute file path, without a name if you don't click on or change the name when recording the action:

 

 

You can check the modal control to make the action step interactive, as highlighted below with the red box:

 

 

Otherwise, you would need a script.

 

P.S. There is a hack to record saving the file to a temporary external file path that is then made unavailable (such as a server or removable device), then the path is shown as "file or folder not found" and the action would then default to the current path. Refer to the second last Save step example below:

 

 

Inspiring
October 29, 2023

Thanks!

The first suggestion doesn't work for me as the problem is not that a new file name is added, but that, even if I do not click or change the name when recording the action - the path is saved and thus "fixed".

Neither does the second suggestion work as I want the rest of the "save as" step to work, it is just the part of the folder selection I do not want and that is not a separate step and thus does not seem to be able to turn off with the modal control.

The third suggestion, the "hack" should probably do the trick  - I haven't tried it yet, but the way it sounds it should work.
Again, many thanks!