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

Stop photoshop adding number suffixes to documents

Community Beginner ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

Normally when opening a file in Photoshop, the document has the same name as the file, and saves as the same name.

For example, if I open "test.PSD" or "test.DNG" or "test.PNG", or whatever, do some edits, then export for web, I get "test.jpg".

However, when opening a RAW file as a smart object (via Adobe Camera RAW), the resulting document has a number appended to it - "<raw filename minus extension>-1"

For example, if I open "test.DNG" as a smart object, I get a document called "test-1", which will save as "test-1.jpg"

Unfortunately my workflow relies on the document having the same name as the file it came from, and this breaks everything.

Does anyone know how to either:

  1. Automate the process of exporting/renaming the file such that it strips off these extra added numbers in some reliable way, or
  2. Stops Photoshop adding the extra numbers to document title in the first place, when opening files as smart objects?

Thanks 🙂

TOPICS
Actions and scripting

Views

1.5K

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

correct answers 1 Correct answer

Community Expert , Feb 22, 2022 Feb 22, 2022

@nedmartin 

 

Here is a v2 code that will loop over all open docs. I have tested this with multiple files opened from ACR as smart objects with the new script being triggered by the Script Event Manager. Please let me know how it goes for you...

 

 

/*
Remove Ending Hyphen Digit from ACR Smart Object Files v2.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/stop-photoshop-adding-number-suffixes-to-documents/m-p/12767371
Stephen Marsh, 23rd February 2022, v2.0
Note: Use the scri
...

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

I'm thinking that a simple script to duplicate the current file removing the -# digit character and close down the original file (conditions that the file must have a -\d+$ and that the active layer is a smart object (possibly further checks to see if the image was processed by ACR through metadata etc).

 

This would be automated via the Scripts Events Manager for opened files (if such files passed by ACR are triggered by the open event).

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 21, 2022 Feb 21, 2022

Copy link to clipboard

Copied

Here is the basic script, which does indeed work with the open event in Script Events Manager:

 

/*
Remove Ending Hyphen Digit from ACR Smart Object Files.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/stop-photoshop-adding-number-suffixes-to-documents/m-p/12767371
Stephen Marsh, 22nd February 2022, v1.0
Note: Use the scripts events manager open event to run this script
*/

try {
    // Previously saved doc
    if (activeDocument.path) {}
} catch (e) {
    // Unsaved doc
    if (ExternalObject.AdobeXMPScript === undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
    var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData);
    var crsMeta = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Version");
    if (activeDocument.name.match(/-\d+$/) && activeDocument.activeLayer.kind === LayerKind.SMARTOBJECT && activeDocument.layers.length === 1 && crsMeta !== undefined) {
        var origDoc = activeDocument;
        var docName = origDoc.name.replace(/-\d+$/, '');
        origDoc.duplicate(docName, false);
        origDoc.close(SaveOptions.DONOTSAVECHANGES);

    }
}

 

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 22, 2022 Feb 22, 2022

Copy link to clipboard

Copied

@nedmartin 

 

Please let me know how the script works for you.

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 Beginner ,
Feb 22, 2022 Feb 22, 2022

Copy link to clipboard

Copied

Thanks for this script. I'm surprised how quickly it works.

 

Unfortunatly there is an issue. If I open a single RAW file, it works perfectly. However, if I open more than one RAW file at a time, only the most recent opened file is renamed. I almost always open more than one RAW file at a time, due to ACR's batch features, and as far as I can tell, there's no way for me to open them one at a time - if I don't open all of them, ACR just closes and I have to re-open it to open the next file/s.

 

Also, what does this line do? From what I can tell, it's not actually doing anything?

if (ExternalObject.AdobeXMPScript === undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

 

On the off-chance it makes any difference, here is the full script I run on "Open Document":

// if file is *.jpeg, RGB 8 bit, then convert to 16 bit
if(
	/jp.?g$/i.test(activeDocument.name)
	&& activeDocument.mode == DocumentMode.RGB
	&& activeDocument.bitsPerChannel == BitsPerChannelType.EIGHT
) {
	activeDocument.bitsPerChannel = BitsPerChannelType.SIXTEEN;

	runMenuItem(app.charIDToTypeID("FtOn")); // FIT TO SCREEN
	// runMenuItem(app.charIDToTypeID("ZmOt")); // ZOOM -
	// runMenuItem(app.charIDToTypeID("ZmIn")); // ZOOM +
	// runMenuItem(app.charIDToTypeID("ActP")); // ACTUAL PIXEL
}

// if file is *.TIFF, then fullscreen it
if(/tiff?$/i.test(activeDocument.name)) {
	runMenuItem(app.charIDToTypeID("FtOn")); // FIT TO SCREEN
}

// if file is *.CR3, then fullscreen it
if(/cr3$/i.test(activeDocument.name)) {
	runMenuItem(app.charIDToTypeID("FtOn")); // FIT TO SCREEN
}

// if file is *.DNG, then fullscreen it
if(/dng$/i.test(activeDocument.name)) {
	runMenuItem(app.charIDToTypeID("FtOn")); // FIT TO SCREEN
}

// if file is 20210912_054920_R6_3054 (object opened from RAW), then fullscreen it
// if(/R6_\d{4}$/i.test(activeDocument.name)) {
// 	runMenuItem(app.charIDToTypeID("FtOn")); // FIT TO SCREEN
// }



/*
Remove Ending Hyphen Digit from ACR Smart Object Files.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/stop-photoshop-adding-number-suffixes-to-documents/m-p/12767371
Stephen Marsh, 22nd February 2022, v1.0
Note: Use the scripts events manager open event to run this script
*/

try {
    // Previously saved doc
    if (activeDocument.path) {}
} catch (e) {
    // Unsaved doc
    if (ExternalObject.AdobeXMPScript === undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
    var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData);
    var crsMeta = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Version");
    if (activeDocument.name.match(/-\d+$/) && activeDocument.activeLayer.kind === LayerKind.SMARTOBJECT && activeDocument.layers.length === 1 && crsMeta !== undefined) {
        var origDoc = activeDocument;
        var docName = origDoc.name.replace(/-\d+$/, '');
        origDoc.duplicate(docName, false);
        origDoc.close(SaveOptions.DONOTSAVECHANGES);

        runMenuItem(app.charIDToTypeID("FtOn")); // FIT TO SCREEN
    }
}

 

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 22, 2022 Feb 22, 2022

Copy link to clipboard

Copied


@nedmartin wrote:

Thanks for this script. I'm surprised how quickly it works.

 

Unfortunatly there is an issue. If I open a single RAW file, it works perfectly. However, if I open more than one RAW file at a time, only the most recent opened file is renamed.

 

I only tested one file at a time... I can confirm your results with multiple docs, with further testing it appears that the open event is only triggered on the last file and not for each file. I'll offer a revised version to process all open documents.

 


 

Also, what does this line do? From what I can tell, it's not actually doing anything?

if (ExternalObject.AdobeXMPScript === undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

 

 

It is part of the conditional check to ensure that the script is only applied to documents that have Camera Raw Settings metadata. I copied it from other code, so it may not be required, I didn't check if it was required or not and it seemed better to leave it in there as I didn't know any better.

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 22, 2022 Feb 22, 2022

Copy link to clipboard

Copied

@nedmartin 

 

Here is a v2 code that will loop over all open docs. I have tested this with multiple files opened from ACR as smart objects with the new script being triggered by the Script Event Manager. Please let me know how it goes for you...

 

 

/*
Remove Ending Hyphen Digit from ACR Smart Object Files v2.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/stop-photoshop-adding-number-suffixes-to-documents/m-p/12767371
Stephen Marsh, 23rd February 2022, v2.0
Note: Use the scripts events manager open event to run this script
*/

#target photoshop

// CHECK FOR OPEN DOCS
if (documents.length) {

    // LOOP OVER OPEN FILES
    for (var i = 0; i < documents.length; i++) {
        activeDocument = documents[i];
        try {
            // PREVIOUSLY SAVED DOC
            if (activeDocument.path) {}
        } catch (e) {
            // UNSAVED DOC
            if (ExternalObject.AdobeXMPScript === undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
            var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData);
            var crsMeta = xmp.getProperty(XMPConst.NS_CAMERA_RAW, "Version");
            if (activeDocument.name.match(/-\d+$/) && activeDocument.activeLayer.kind === LayerKind.SMARTOBJECT && activeDocument.layers.length === 1 && crsMeta !== undefined) {
                var origDoc = activeDocument;
                var docName = origDoc.name.replace(/-\d+$/, '');
                origDoc.duplicate(docName, false);
                origDoc.close(SaveOptions.DONOTSAVECHANGES);
                // END OF SCRIPT NOTIFICATION
                app.beep();
            }
        }
    }


    // ALERT IF NO DOCS OPEN
} else {
    alert('You must have a document open!');
}

 

 

 

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
Explorer ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

I wish there was a solution that didn't require a computer science degree.  I don't know what any of this means, I don't know how to run scripts.

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
LEGEND ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

Scripting really unlocks a huge amount of image processing power in Photoshop. Consider this a chance to expand your skills.

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
Explorer ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

I'm a photographer.  If I wanted to be a coder, I'd be a coder.

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
LEGEND ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

I'm a working pro photographer myself and I'm willing to use any tool I can to do my job. My boss doesn't pay me to complain, he pays for results. Maybe you have a different approach, that's fine. But then you have to live with the limitations of the tools.

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
Explorer ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

LATEST

I have no boss, and I have no time or inclination to learn how to become a computer programmer.  So if that means I have to delete the "-1" at the end of the file name every time I save, so be it.

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 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

@nedmartin 

 

So how did the new v2 script work for you?

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 Beginner ,
Feb 23, 2022 Feb 23, 2022

Copy link to clipboard

Copied

I haven't had time to test it extensively but so far it seems to be working great! Thank you!

 

I discovered that it does actually run my script for every RAW file even when I open more than one, but that the activeDocument is the same each time, which is why it was only changing the one document and not working on the others. So it's probably quite inefficient - if I open 4 RAW files, this script runs 4 times, loops through all the documents and does its stuff the first time, and then loops another 3 times but doesn't do anything because it already did it and now their names don't match...

Seems to handle it fine and does exactly what I want, just bothers me slightly that it can't work efficiently on just the newly opened files like it's supposed to... Oh well! Probably a bug in the way Photoshop handles smart objects or files from Adobe Camera RAW I guess.

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 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

From my very basic testing, Script Events Manager appears to trigger the script once, when the final doc is opened from ACR (not one doc at a time, they are opened as a single batch). So if you are loading 4 docs as smart objects into Photoshop from ACR, once the 4th final doc is opened then the SEM is triggered and my script will loop over all open files.

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
Engaged ,
Nov 15, 2023 Nov 15, 2023

Copy link to clipboard

Copied

I see the same issue and will try @Stephen_A_Marsh's script – thanks a lot! Was this issue ever reported to Adobe? Appending this number is nonsensical and should get avoided in the first place.


I embed a RAW with filename.raw into a Photoshop file and perform operations which require saving in the psd format. A PSD with filename.psd does not yet exist in the same folder, there's no naming conflict. Why does Photoshop still append a number? That cannot be useful for anyone.

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
Explorer ,
Apr 30, 2024 Apr 30, 2024

Copy link to clipboard

Copied

This is my issue.  I am a novice when it comes to scripts and programming so none of these solutions make any sense to me.  I also can't reliably reproduce it, so I don't know what's causing it.  Sometimes it does it, sometimes it doesn't.  I can understand the -1 or -2 if you have multiple instances of the same file open, but otherwise there is no reason for PS to add that suffix in the first place.  If I open 1234.NEF, I want it to save as 1234.PSD.  1234-1.PSD makes no sense.  Hopefully Adobe removes this or at least makes it a checkbox option in preferences or something.  

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 ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

Hey not sure if you have found the solution yet but the simple answer for anyone looking in the future: Is to make sure that camera raw is opening your images as normal images, not smart objects. So to do this simply open up your camera raw preference panel then go to workflow, here you should see a checkbox labeled "open in photoshop as smart object" make sure that's unchecked.  When this option is unchecked the open button in camera raw will read as "open" when it is checked camera raw will say "open objects" (I don't know why exactly but I've found that photoshop only adds these suffixes to smart objects.) Also you can shift, click to overide the selected preference. I.e if your raw simply says "open" (normal image) shift clicking will open your image as a smart object or if it reads "open object" shift click will open as a normal image and not add a suffix. Hope that makes sense and helps whoever needs it.Screenshot 2024-08-30 124756.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 ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

I know the original post said opening smart objects specifically but this is the only work around I've found without the use of scripts.

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
Explorer ,
Aug 30, 2024 Aug 30, 2024

Copy link to clipboard

Copied

Thanks for that info, I will check that out.  It still kind of stinks because I want it to be a Smart Object.  I guess I can toggle that off and then once it's open, convert it to a Smart Object, but then that's really no different than changing the file name when I save it, it's still an extra step.  Still though, thanks for the reply.

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