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

Save pictures with a unique (random) name

Community Beginner ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

When saving a picture, it shoud be possibele to save it with a unique (random) name. Then when making a save action, it won't overwrite the original file.

Idea No status
TOPICS
Actions and scripting , Windows

Views

385

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
7 Comments
Community Expert ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

That's what "Save As" is for.

 

Random names isn't going to get much support here.

 

Votes

Translate

Translate

Report

Report
Community Expert ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

A random name could be scripted if you need this now.

 

I believe that Photoshop really needs the ability to add "variable tokens" into the filename. The tokens are not literal characters, they are metacharacters that the save naming routine would "translate" into literal characters. The token could also offer parameters, such as the number of digits required.

 

As an example, the filename entry could be:

 

My great digital painting_\\random-digits,6\\

 

And when saved as say a JPEG the result would be:

 

My great digital painting_542876.jpg

 

In this example, I have used illegal filename characters \\ as "reserved" special characters to designate the token. There could be a checkbox to enable tokens, or a preference setting. It would be helpful that there was a option in the GUI to select and insert the token rather than relying on the user to type it correctly.

 

I have added this a separate feature request:

https://community.adobe.com/t5/photoshop-ecosystem-ideas/add-variable-save-filename-tokens-to-save-e...

 

Votes

Translate

Translate

Report

Report
Community Expert ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

The following code will bring up the Save a Copy dialog with the current filename with an added underscore and pseudo-random digits appended, i.e.:

 

Untitled-1_1963700736.psd

 

#target photoshop

try {
    var outputPath = app.activeDocument.path.fsName;
} catch (e) {
    var outputPath = Folder.selectDialog("Unsaved file, select the output folder:");
}
var pseudoRandomDigits = (Math.random() * 1e10);
pseudoRandomDigits = Math.round(pseudoRandomDigits);
var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var idsave = stringIDToTypeID("save");
var desc617 = new ActionDescriptor();
var idas = stringIDToTypeID("as");
var desc618 = new ActionDescriptor();
var idmaximizeCompatibility = stringIDToTypeID("maximizeCompatibility");
desc618.putBoolean(idmaximizeCompatibility, true);
var idphotoshopthreefiveFormat = stringIDToTypeID("photoshop35Format");
desc617.putObject(idas, idphotoshopthreefiveFormat, desc618);
var idin = stringIDToTypeID("in");
desc617.putPath(idin, new File(outputPath + "/" + docName + "_" + pseudoRandomDigits));
var idcopy = stringIDToTypeID("copy");
desc617.putBoolean(idcopy, true);
var idlowerCase = stringIDToTypeID("lowerCase");
desc617.putBoolean(idlowerCase, true);
executeAction(idsave, desc617, DialogModes.ALL);

 

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

Votes

Translate

Translate

Report

Report
Community Beginner ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

this is a not2 my waist of my time aim starting in my earning Please help
me

Votes

Translate

Translate

Report

Report
Community Expert ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

quote

this is a not2 my waist of my time aim starting in my earning Please help
me


By @no bde 

 

This doesn't make sense, please post in your native language and we'll use translation software to try to reply.

Votes

Translate

Translate

Report

Report
Community Beginner ,
Aug 02, 2024 Aug 02, 2024

Copy link to clipboard

Copied

Thank you for the script. I see I can specify the folder I want, but I can't see the way to save the image as a jpeg without dialogs. Any suggestion?

Votes

Translate

Translate

Report

Report
Community Expert ,
Aug 02, 2024 Aug 02, 2024

Copy link to clipboard

Copied

LATEST
quote

Thank you for the script. I see I can specify the folder I want, but I can't see the way to save the image as a jpeg without dialogs. Any suggestion?


By @felixpq 

 

That is correct, the script was designed to offer an interactive save, defaulting to PSD.

 

The following code will save a JPEG to the open document path or ask for a save location if the source file is unsaved. Existing files with the same name will be overwritten, as pseudo-random doesn't guarantee a unique name.

 

#target photoshop

try {
    var outputPath = app.activeDocument.path.fsName;
} catch (e) {
    var outputPath = Folder.selectDialog("Unsaved file, select the output folder:");
}
var pseudoRandomDigits = (Math.random() * 1e10);
pseudoRandomDigits = Math.round(pseudoRandomDigits);
var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var saveOptions = new JPEGSaveOptions();
saveOptions.embedColorProfile = true;
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
saveOptions.matte = MatteType.NONE;
saveOptions.quality = 10;
app.activeDocument.saveAs(File(outputPath + "/" + docName + "_" + pseudoRandomDigits + ".jpg"), saveOptions, true);

Votes

Translate

Translate

Report

Report