Skip to main content
Shlomit Heymann
Inspiring
April 26, 2022
Answered

Cancel Suffix Number Addition When Reopen Raw filess (CR2)

  • April 26, 2022
  • 3 replies
  • 1201 views

Hello,

Since one of the latest updates (I don’t remember which one), everytime I reopen a Raw file (CR2 in my case), Photoshop auto adds a suffix number after the file name.

 

Can I cancel this behaviour?

 

Thank you

Shlomit

This topic has been closed for replies.
Correct answer Stephen Marsh

I'll post an updated version... If you are not opening the raw files as smart objects, I'll need to modify the previously linked script...

 

Edit: @Shlomit Heymann – here is the updated version for use with raw files from ACR which are not smart objects. Please let me know if there are any issues and or if it works OK for you:

 

/*
Remove Ending Hyphen Digit from ACR Files.jsx
Stephen Marsh, 26th April 2022, v1.0
https://community.adobe.com/t5/photoshop-ecosystem-discussions/cancel-suffix-number-addition-when-reopen-raw-filess-cr2/td-p/12904160
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/stop-photoshop-adding-number-suffixes-to-documents/m-p/12767371
Note: Use the Scripts Events Manager - Open Document event to automatically run this script when opening files from Adobe Camera Raw
*/

#target photoshop

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

    // LOOP OVER OPEN FILES
    for (var i = 0; i < documents.length; i++) {
        activeDocument = documents[i];
        // PROCESS FILES WITHOUT A FILENAME EXTENSION
        if (/\.[^\.]+$/i.test(activeDocument.name)) {} else {
            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.isBackgroundLayer && 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!');
}

 

The script is intended to be used via the Script Events Manager for the Open Document event:

https://prepression.blogspot.com/2021/10/photoshop-script-events-manager.html

 

Saving JavaScript Source Code:

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save the text file as .txt
  5. Rename the file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below):

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

 

3 replies

Stephen Marsh
Community Expert
Community Expert
April 27, 2022

@Shlomit Heymann - So, how did the script go?

 

Shlomit Heymann
Inspiring
May 4, 2022

Hi Stephen, 

Thank you very much for your help.

I followed all instructions, but when reopen Bridge I got this error msg:

All the best,

Shlomit

Stephen Marsh
Community Expert
Community Expert
May 4, 2022
Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
April 26, 2022

I'll post an updated version... If you are not opening the raw files as smart objects, I'll need to modify the previously linked script...

 

Edit: @Shlomit Heymann – here is the updated version for use with raw files from ACR which are not smart objects. Please let me know if there are any issues and or if it works OK for you:

 

/*
Remove Ending Hyphen Digit from ACR Files.jsx
Stephen Marsh, 26th April 2022, v1.0
https://community.adobe.com/t5/photoshop-ecosystem-discussions/cancel-suffix-number-addition-when-reopen-raw-filess-cr2/td-p/12904160
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/stop-photoshop-adding-number-suffixes-to-documents/m-p/12767371
Note: Use the Scripts Events Manager - Open Document event to automatically run this script when opening files from Adobe Camera Raw
*/

#target photoshop

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

    // LOOP OVER OPEN FILES
    for (var i = 0; i < documents.length; i++) {
        activeDocument = documents[i];
        // PROCESS FILES WITHOUT A FILENAME EXTENSION
        if (/\.[^\.]+$/i.test(activeDocument.name)) {} else {
            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.isBackgroundLayer && 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!');
}

 

The script is intended to be used via the Script Events Manager for the Open Document event:

https://prepression.blogspot.com/2021/10/photoshop-script-events-manager.html

 

Saving JavaScript Source Code:

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save the text file as .txt
  5. Rename the file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below):

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

 

Stephen Marsh
Community Expert
Community Expert
April 26, 2022

@Shlomit Heymann – Not that I am aware of.

 

I wrote a script for another user to automatically dupe/rename... but I can't find it in my archive.

 

I'll see if I can find it on the forum.

 

EDIT: Here it is –