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

Automate > Batch keeps overwriting the current file.

New Here ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

Hi everyone, 

 

I am new to using Photoshop Actions but I created one that acheived my goal of opening a background image, applying a PNG overlay, Saving for Web, deleting the overlay layer, repeating the process with a few different overlays on the same background image, and closing the file. 

When I run the action on one backgroud image it works great. However, when I do Automate > Batch on an entire folder of background images it just keeps replacing the set of images over and over. 

I need to somehow append a name to each file so they dont overwrite. Here's an example of what I need from each background:


background_red-overlay.png

background_green-overlay.png

background_blue-overlay.png

 

If someone could help me with this I would greatly appreciate it!

TOPICS
Actions and scripting

Views

1.7K

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 Expert ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

Batch uses the Action you chose, if the name and path of the resulting file/s are part of the recording that’s not a malfunction of Batch. 

Please provide meaningful screenshots including the fully expanded Action in the Actions Panel and the Layers Panel. 

 

If you need to amend filenames you will probably have to use a Script instead of an Action. Do you have any JavaScript experience? 

 

 

Votes

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 ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

Screen Shot 2020-11-17 at 12.16.39 PM.pngScreen Shot 2020-11-17 at 12.16.49 PM.pngScreen Shot 2020-11-17 at 12.16.58 PM.pngScreen Shot 2020-11-17 at 12.17.12 PM.png

Votes

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 ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

I collapsed the repitive place/exports bc its the same exact thing as above I just used a different overlay. 

Votes

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 ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

I have no JavaScript experience but I am willing to try anything! 

Votes

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
Community Expert ,
Nov 18, 2020 Nov 18, 2020

Copy link to clipboard

Copied

This would export a png with the file’s name plus the active layer’s name. 

 

// 2020, use it at your own risk;
#target photoshop;
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
// getting the name and location;
var docName = myDocument.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
var myDocument = app.activeDocument;
var docName = myDocument.name;  
try {var basename = docName.match(/(.*)\.[^\.]+$/)[1]} 
catch (e) {var basename = docName};
try {var docPath = myDocument.path}
catch (e) {var docPath = "~/Desktop"};
// layer name;
try {
var layername = myDocument.activeLayer.name;
var basename = basename + "_" + layername;
} catch (e) {};
// save png;
savePNG (myDocument, docPath, basename, "_a");
};
////// function to png //////
function savePNG (myDocument, docPath, basename, theSuffix) {
// weboptions;
var webOptions = new ExportOptionsSaveForWeb();
webOptions.format = SaveDocumentType.PNG;
webOptions.PNG8 = false;	
webOptions.transparency = true;
webOptions.interlaced = 0;
webOptions.includeProfile = false;
webOptions.optimized = true;
myDocument.exportDocument(new File(docPath+"/"+basename+theSuffix+".png"), ExportType.SAVEFORWEB, webOptions);
};

 

Votes

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
Community Expert ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

In the Batch interface, check/tick the "override action open" option...

 

Or remove or disable the open step from the action.

 

Batch opens files, so your action step to open an explicit file is conflicting with Batch, which is why it needs to be overriden or removed/disabled.

Votes

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 ,
Feb 03, 2023 Feb 03, 2023

Copy link to clipboard

Copied

Im having this same issure with a very simple action, any help would be super appreciated

 

action.jpg

Votes

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
Community Expert ,
Feb 03, 2023 Feb 03, 2023

Copy link to clipboard

Copied

There is no "save as" or "save as a copy" step visible in your action, however, it sounds like there is one there.

 

In Batch, you need to check the "override action 'save as' commands" checkbox to avoid overwriting using the name recorded in the action save as step.

 

EDIT: Otherwise, look at my earlier 2020 reply regarding the use of override open command in batch.

 

https://helpx.adobe.com/photoshop/using/processing-batch-files.html#process_a_batch_of_files

 

Override Action "Save As" Commands

Ensures that processed files are saved to the destination folder specified in the Batch command (or to their original folder if you chose Save and Close), with their original names or the names you specified in the File Naming section of the Batch dialog box.

If you don't select this option and your action includes a Save As command, your files will be saved into the folder specified by the Save As command in the action, instead of the folder specified in the Batch command. In addition, if you don't select this option and the Save As command in the action specifies a filename, the Batch command overwrites the same file (the file specified in the action) each time it processes an image.


 

Votes

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
Community Expert ,
Feb 03, 2023 Feb 03, 2023

Copy link to clipboard

Copied

It is overwriting existing document right? You have step: Duplicate current layer to document with fixed name metal print.psd. Then you are closing document and my guess it will continue working with metal print.psd document. Later you are applying transform and layer style. If you save that document to lets say JPEG without touching anything it will save as metal print.jpg each and every time you run action. Do you understand where is the problem?

Votes

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
Community Expert ,
Feb 04, 2023 Feb 04, 2023

Copy link to clipboard

Copied

You may have a good point there @Bojan Živković 

 

If the action is recording the name of the original doc when duplicating, you will need to do this another way.

This could be using copy/close/paste.

Or possibly by defining a pattern, then filling with a pattern.

A script step could replace the duplicate layer as it can use a generic reference to the index number/name of the second open document rather than recording the actual document name:

 

/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/automate-gt-batch-keeps-overwriting-the-current-file/td-p/11602843
Dupe Active Layer to Next Doc.jsx
By Stephen Marsh
Presumes that there are only two docs open, the source [0] and destination [1]
*/

#target photoshop

if (documents.length === 2 && activeDocument === documents[0]) {
	var sourceLayerName = activeDocument.activeLayer.name;
var targetDocName = documents[1].name;
dupeLayer();
} else {
	// alert("There must be 2 docs open, with the active doc being the first doc!");
	app.beep();
}

function dupeLayer() {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }
	var descriptor = new ActionDescriptor();
	var list = new ActionList();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	reference2.putName( s2t( "document" ), targetDocName );
	descriptor.putReference( s2t( "to" ), reference2 );
	descriptor.putString( s2t( "name" ), sourceLayerName );
	descriptor.putList( s2t( "ID" ), list );
	executeAction( s2t( "duplicate" ), descriptor, DialogModes.NO );
}

 

Votes

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
Community Expert ,
Feb 04, 2023 Feb 04, 2023

Copy link to clipboard

Copied

He is duplicating layer to another document then closing document. Here is how I understand:

 

  • There is metal print.psd document open in Photoshop
  • OP is running batch process with folder full of images
  • Batch script is opening image_1.psd, for example, in Photoshop, duplicating single layer to already open metal print.psd and closing image_1.psd.
  • The next step is working with duplicated layer in metal print.psd with saving
  • Batch is repeating, opening image_2.psd in Photoshop, duplicating single layer to metal print.psd, closing image_2.psd and continue working with metal print.psd with saving over existing.

 

What is mistake here? Batch is always saving same document metal print.psd one over another. Solution? Maybe Image Processor Pro can help because it offers sequential numbering but keep in mind that you should delete duplicated layer after saving or after duplicating layer from the next image into metal print.psd because you will be stacking duplicated layers in metal pring.psd. If thats your goal then ok, if you want single layer as overlay or whatever else keep in mind that you are stacking in batch if you do not delete duplicated layer.

 

Another solution: record step to duplicate layer from open image or current document (image_1.psd, for example), which will be open open in batch process to metal print.psd. Lets call this layer dupliactedLayer. Do not close image open in batch (image_1.psd) but rather select next open document (metal print.psd) using action step. Do whatever you want then select all and use Edit > Copy Merged. Select top most layer or layer that is duplicated/imported (duplicatedLayer) and delete it. Switch back to previous document, that will be image open in batch (image_1.psd), select top most layer if that document is multilayered to ensure pasted content will go on top and paste previously copied content using Copy Merged. You may need to expand canvas using Reveal All or to make some tweaks what I can not tell you without seeing process and documents used for batch.

Votes

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
Community Expert ,
Feb 04, 2023 Feb 04, 2023

Copy link to clipboard

Copied

LATEST

There is a pretty simple way to avoid the action recording the file name: just click on a different destination then back. I discovered this by accident trying to figure out a similar problem.

 

What you want to look at is whether the file name is highlighted in blue in the save dialog. If it isn't, the name isn't recorded, and the action will not overwrite, but save with the original name.

Votes

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