Action to save as Jpeg in origin image folder

New Here ,
Sep 17, 2015 Sep 17, 2015

Copy link to clipboard

Copied

Hello everybody,

I tried to create an action to save as Jpeg but i have a problem.

I open an image, for example in "E:\folder1\"

I play action and surprise Photoshop don't save my image in "E:\folder1\" but save it in the last folder's image i save !

How i can modify action to save image in the same folder where it is originally ?

Thank you to help me and sorry for my very bad english...

TOPICS
Actions and scripting

Views

3.0K

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Sep 17, 2015 Sep 17, 2015

Copy link to clipboard

Copied

Try recording the "Save As" step and not change anything in the save as dialog except the File Type. Only use the file type pull-down menu to select Jpeg.  If you change the Path, Filename, etc fields those changes will be recorded in the action step.  You must record the action on a document that has been save so the document has a backing file. So there will be a default Path and  file name.  When you do not change fields in a "Save As" steps dialog like path and filen ame nothing will be recorded for these settings in that action step.  When that step is played Photoshop will use the current document Path and File Name.  So the action will only work on documents the have a backing file on disk.  It will not wok on new document that have not been saved.  New documents do not have a backing file till they have been saved.  You can also use menu File>Automate>Batch  and uset it override save as steps option to overide  Save As steps settings.

This question should be in the Photoshop General Discussion forum.

Crafting Actions Package UPDATED Aug 10, 2014 Added Conditional Action steps to Action Palette Tips.
Contains

Example
Download

JJMack

Likes

Translate

Translate

Report

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
New Here ,
Sep 17, 2015 Sep 17, 2015

Copy link to clipboard

Copied

Hi, Thanks for you quick response.

I tried recording without change file destination but Path is automatically save by Photoshop 😞

Likes

Translate

Translate

Report

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
New Here ,
Dec 18, 2015 Dec 18, 2015

Copy link to clipboard

Copied

Hi

did you find a solution for that, i got the same problem, the folder path is not set as default whatever i do.

Please help !

Likes

Translate

Translate

Report

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 ,
Dec 19, 2015 Dec 19, 2015

Copy link to clipboard

Copied

Bonjour

With this :

var saveFile = new File(activeDocument.path);

activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 19, 2015 Dec 19, 2015

Copy link to clipboard

Copied

Yes its easy in a Script but the Op wanted to create a action. Actions have very limited save as capabilities.   Batching a action can override save as steps to change the destination recorded in the Action step.

JJMack

Likes

Translate

Translate

Report

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
New Here ,
Dec 20, 2015 Dec 20, 2015

Copy link to clipboard

Copied

Thanks for the answer,

Being a beginner in scripting, I only know how to create one via the photoshop script panel.

How is it possible to edit the script to insert your commands ?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 20, 2015 Dec 20, 2015

Copy link to clipboard

Copied

Actions are not the same thing as Scripts.

Scripts can be inserted into actions, however I doubt that is what you wish to do in this case.

Listen to JJMack’s advice on actions.

Likes

Translate

Translate

Report

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
New Here ,
Dec 20, 2015 Dec 20, 2015

Copy link to clipboard

Copied

When working on a PSD file, I only want to press a key on my keyboard to save the file in jpg in the origin folder.

Why should i use batching an action for that as JJmack said ?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 20, 2015 Dec 20, 2015

Copy link to clipboard

Copied

JJMack was informing you how actions work, not how you wished they work – which are two different things.

As fantastic as Photoshop actions are, they still have limitations. Scripts are more flexible, however not as accessible to non-coders as actions. For example, the previous script in post #4 errors for me.

You can insert a script into an action, then invoke the playback of the action from a keyboard shortcut – or you can setup a direct keyboard shortcut on the script without referencing it in an action.

A similar script to the one that you are looking for can be found here:

https://forums.adobe.com/message/4453915#4453915

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 20, 2015 Dec 20, 2015

Copy link to clipboard

Copied

Look Photoshop is massive it takes a long time to learn how to use Photoshop well. Don't try to rush it. Relax and don't be tense or up tight.  As long as you work on copies of the your original camera images you will not do any harm.  Play with Photoshop treat it as a toy have fun the more you play the more you learn.  It also helps to read and ask questions.  Some no many things are not as straight forward as you think that they would be in Photoshop.   The more you learn about how Photoshop works makes it easer to understand how other things may work.  You will learn at a much faster passe then.  Till then relax have fun.  When you get there you will be relaxed in Photoshop and you will be very productive using it. I don't thing a day will go by the you will not discover something else about Photoshop.  Even thing you think you know cold you will realize other things about these features.  No one uses every thing Photoshop can do. And many tings can be done using different methods.  Some methods may produce better results. However you do something if the result are acceptable to you that all that matters.

JJMack

Likes

Translate

Translate

Report

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
New Here ,
Dec 20, 2015 Dec 20, 2015

Copy link to clipboard

Copied

never was expecting this kind of philosophic answer JJ, it does not help me that much. I use PS since many years and enjoy it thanks.

Well now i manage to create the script in javascript :

#target photoshop

var saveFile = new File(activeDocument.path);

// =======================================================

var idsave = charIDToTypeID( "save" );

    var desc8 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

        var desc9 = new ActionDescriptor();

        var idEQlt = charIDToTypeID( "EQlt" );

        desc9.putInteger( idEQlt, 12 );

        var idMttC = charIDToTypeID( "MttC" );

        var idMttC = charIDToTypeID( "MttC" );

        var idNone = charIDToTypeID( "None" );

        desc9.putEnumerated( idMttC, idMttC, idNone );

    var idJPEG = charIDToTypeID( "JPEG" );

    desc8.putObject( idAs, idJPEG, desc9 );

    var idIn = charIDToTypeID( "In  " );

    desc8.putPath( idIn, new File( saveFile ) );

    var idDocI = charIDToTypeID( "DocI" );

    desc8.putInteger( idDocI, 35 );

    var idCpy = charIDToTypeID( "Cpy " );

    desc8.putBoolean( idCpy, false );

    var idLwCs = charIDToTypeID( "LwCs" );

    desc8.putBoolean( idLwCs, true );

    var idsaveStage = stringIDToTypeID( "saveStage" );

    var idsaveStageType = stringIDToTypeID( "saveStageType" );

    var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );

    desc8.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );

executeAction( idsave, desc8, DialogModes.NO );


Now I just need to assign a shortcut to it. Do I need to change my jsx file to an atn one or is there another solution ?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 20, 2015 Dec 20, 2015

Copy link to clipboard

Copied

Now I just need to assign a shortcut to it. Do I need to change my jsx file to an atn one or is there another solution ?

If you have the script installed and available in the File/Scripts menu, then all you need to do is go to the Edit/Keyboard Shortcuts menu and add a custom shortcut under Application Menus/File/Scripts against your installed script.

There is no need to insert the script into an action and setup keyboard shortcuts against the action, however that is also an option.

Likes

Translate

Translate

Report

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
New Here ,
Dec 20, 2015 Dec 20, 2015

Copy link to clipboard

Copied

Thanks Stephen, that was what i found at the same time, perfect ! 🙂

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 21, 2015 Dec 21, 2015

Copy link to clipboard

Copied

Just remember the script will not work with new documents.  There must be a backing file for there to be an activedocument path. Try the one liner on a new document that has not been saved yet.

alert(activeDocument.path);

You could catch the error

#target photoshop

try {

var saveFile = new File(activeDocument.path);

// =======================================================

var idsave = charIDToTypeID( "save" );

    var desc8 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

        var desc9 = new ActionDescriptor();

        var idEQlt = charIDToTypeID( "EQlt" );

        desc9.putInteger( idEQlt, 12 );

        var idMttC = charIDToTypeID( "MttC" );

        var idMttC = charIDToTypeID( "MttC" );

        var idNone = charIDToTypeID( "None" );

        desc9.putEnumerated( idMttC, idMttC, idNone );

    var idJPEG = charIDToTypeID( "JPEG" );

    desc8.putObject( idAs, idJPEG, desc9 );

    var idIn = charIDToTypeID( "In  " );

    desc8.putPath( idIn, new File( saveFile ) );

    var idDocI = charIDToTypeID( "DocI" );

    desc8.putInteger( idDocI, 35 );

    var idCpy = charIDToTypeID( "Cpy " );

    desc8.putBoolean( idCpy, false );

    var idLwCs = charIDToTypeID( "LwCs" );

    desc8.putBoolean( idLwCs, true );

    var idsaveStage = stringIDToTypeID( "saveStage" );

    var idsaveStageType = stringIDToTypeID( "saveStageType" );

    var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );

    desc8.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );

executeAction( idsave, desc8, DialogModes.NO );

}

catch(e) { alert("Document needs to be saved");}

JJMack

Likes

Translate

Translate

Report

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
Explorer ,
Apr 23, 2016 Apr 23, 2016

Copy link to clipboard

Copied

Hi, I've spent several hours searching for an answer for this (I want to: save jpeg to original folder, into sRGB, adding a surfix to the filename). But if " the script will not work with new documents", it seems odd: the purpose is to save file but you have to save it first.

Drives me crazy.

Likes

Translate

Translate

Report

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
Guide ,
Apr 24, 2016 Apr 24, 2016

Copy link to clipboard

Copied

Please explain where the original folder is for a document that has not been saved.

Ok I will answer that, there isn't one !

What you have to do is decide where you want to save documents that have not been saved.

As an example they will be save to the desktop ...

#target photoshop;

if(documents.length){

var doc = activeDocument;

if (doc.colorProfileName.substring(0,4) != "sRGB")

    doc.convertProfile("sRGB IEC61966-2.1", Intent.PERCEPTUAL, true, false);

try{

     Path = doc.path;

    }catch(e){

        //this document has not been saved.

        Path = Folder.desktop;

        }

var Name = doc.name.replace(/\.[^\.]+$/, '');

var saveFile = File(Path+ "/" + Name + "mySuffix" + ".jpg");

SaveForWeb(saveFile,80);

}   

function SaveForWeb(saveFile,jpegQuality) {

var sfwOptions = new ExportOptionsSaveForWeb();

   sfwOptions.format = SaveDocumentType.JPEG;

   sfwOptions.includeProfile=true;

   sfwOptions.interlaced = 0;

   sfwOptions.optimized = true;

   sfwOptions.quality = jpegQuality;

activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

};

Likes

Translate

Translate

Report

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
Explorer ,
Apr 24, 2016 Apr 24, 2016

Copy link to clipboard

Copied

LATEST

Thank you very much for the help.

The "Path = Folder.desktop" line is great. Also your code about sRGB is inspiring, I googled and didn't find that.

Yesterday I tried  Paul Riggott 's code in this thread:

How to incrementally save images using a hotkey

It works fine. It can add incremental suffix like _001, _002. And using SaveAs instead of SaveForWeb is good, too, since SaveForWeb has a file size limitation for jpegs output.

Likes

Translate

Translate

Report

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