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

Action to save as Jpeg in origin image folder

New Here ,
Sep 17, 2015 Sep 17, 2015

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
10.0K
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
Adobe
Community Expert ,
Sep 17, 2015 Sep 17, 2015

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

Hi, Thanks for you quick response.

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

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

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 !

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

Bonjour

With this :

var saveFile = new File(activeDocument.path);

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

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

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

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 ?

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

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.

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

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 ?

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

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

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

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

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 ?

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

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

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

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

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

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.

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

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);

};

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

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.

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
Explorer ,
Jan 25, 2023 Jan 25, 2023

How can I save in psd , instead of jpg? 

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 ,
Jan 25, 2023 Jan 25, 2023
quote

How can I save in psd , instead of jpg? 


By Rafael _ Oz


Which of the multiple scripts posted in this topic do you want altered?

 

Is it the one from @SuperMerlin ?

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
Explorer ,
Jan 26, 2023 Jan 26, 2023

I tried to modify the one from @waccoo79

using "chatGpt". But no sucess. I get general error on the end. changing the jpg to .psd.

Thanks !

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 ,
Jan 26, 2023 Jan 26, 2023

@Rafael _ Oz â€“ I doubt that ChatGPT has been trained on AM code if you were trying to get it to modify that script.

 

Here it is using standard DOM code. There is no code to check for whether a document path exists, but it could be added:

 

#target photoshop
var psdOptions = new PhotoshopSaveOptions();
psdOptions.embedColorProfile = true;
psdOptions.alphaChannels = true;
psdOptions.layers = true;
psdOptions.spotColors = true;
psdOptions.annotations = true;
activeDocument.saveAs(new File(activeDocument.path + '/' + activeDocument.name.split('.')[0] + '.psd'), psdOptions, true);

 

It currently uses Save As a Copy, leaving the original JPEG or whatever file open. Change the true to false in the final save as line to Save As where the PSD would become the open doc.

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
Explorer ,
Jan 26, 2023 Jan 26, 2023

Worked perfectly ! Thanks. There is a way to close the current document without prompt the user? 

 

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 ,
Jan 26, 2023 Jan 26, 2023

Rafael _ Oz wrote:

Worked perfectly ! Thanks. There is a way to close the current document without prompt the user? 

 


 

Sure, add this line to the end:

 

activeDocument.close(SaveOptions.DONOTSAVECHANGES);

 

(remove DONOT to save) 

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
Explorer ,
Jan 26, 2023 Jan 26, 2023

Thanks ! helped a lot. 

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