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

Script to remove 'copy' from crop and straightened images.

Community Beginner ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

Hi I'm looking for a script that removes the word ' copy,' from files that have been cropped and straightened. Thanks.

TOPICS
Actions and scripting

Views

252

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 , Oct 09, 2022 Oct 09, 2022
quote

I could rename afterwards using bridge or lupas rename which I have been doing but was hoping there was a way to script it in the action.


By @Joseph Brown

 

After the Action step for Crop and Straighten Photos, record the following script into the Action:

 

/*
Remove Copy from Open Doc Names.jsx
Stephen Marsh, 9th October 2022, v1.0
https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-remove-copy-from-crop-and-straightened-images/td-p/13253044
Based on:
https://community.ad
...

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

@Joseph Brown – Is there a special reason why you need to do this in a Photoshop script?

 

After the fact, this is easy to do with Adobe Bridge's Batch Rename command.

 

Standard:

 

Find: copy

Replace:

 

(find a space followed by copy, replace with nothing to delete it).

 

2022-10-08_13-33-51.png

 

With a regular expression –

 

Find:

(.+)( copy)(\.[^\.]+$)

 

Replace:

$1$3

 

2022-10-08_13-32-55.png

 

2022-10-08_13-50-03.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
Mentor ,
Oct 08, 2022 Oct 08, 2022

Copy link to clipboard

Copied

how would any app know which images have been cropped and/or straightened?

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 ,
Oct 08, 2022 Oct 08, 2022

Copy link to clipboard

Copied

I posted this question in the Photoshop ecosystem message board, so Photoshop is the app I'm using.

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 ,
Oct 08, 2022 Oct 08, 2022

Copy link to clipboard

Copied

I've got a few thousand objects shot with on a large black background and have created an action to select the object, crop and straighten with a 100px black border. I could rename afterwards using bridge or lupas rename which I have been doing but was hoping there was a way to script it in the action.

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
Mentor ,
Oct 08, 2022 Oct 08, 2022

Copy link to clipboard

Copied

i'm sorry, but why is copy in their name to begin with? Very little of what you're doing here makes any sense. Just use Image Processor Pro or Batch to automate this task and you'll not have to rename anything after the fact.

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 ,
Oct 08, 2022 Oct 08, 2022

Copy link to clipboard

Copied

quote

i'm sorry, but why is copy in their name to begin with?


By @Earth Oliver

 

Because the File > Automate > Crop and Straighten Photos command duplicates the original file and appends a space+copy+space+digits on each image that is extracted and cropped and straightened.

 

The OP would simply like to streamline the workflow into a single step, rather than batch renaming the saved files as a second step.

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
Mentor ,
Oct 09, 2022 Oct 09, 2022

Copy link to clipboard

Copied

ohhhh. I thought they were manually doing the crop/straighten.

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 ,
Oct 09, 2022 Oct 09, 2022

Copy link to clipboard

Copied

quote

I could rename afterwards using bridge or lupas rename which I have been doing but was hoping there was a way to script it in the action.


By @Joseph Brown

 

After the Action step for Crop and Straighten Photos, record the following script into the Action:

 

/*
Remove Copy from Open Doc Names.jsx
Stephen Marsh, 9th October 2022, v1.0
https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-remove-copy-from-crop-and-straightened-images/td-p/13253044
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/cancel-suffix-number-addition-when-reopen-raw-filess-cr2/td-p/12904160
https://community.adobe.com/t5/photoshop-ecosystem-discussions/stop-photoshop-adding-number-suffixes-to-documents/m-p/12767371
*/

#target photoshop

// CHECK FOR OPEN DOCS
if (documents.length) {
    removeCopy();
    // WHY?
    removeCopy();
    // END OF SCRIPT
    app.beep();

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

function removeCopy() {
    try {
        // IGNORE SAVED FILES
        app.activeDocument.path;
    } catch (e) {
        // LOOP OVER OPEN UNSAVED DOCS
        for (var i = 0; i < documents.length; i++) {
            activeDocument = documents[i];
            // PROCESS DOCS WITHOUT A FILENAME EXTENSION
            if (/\.[^\.]+$/i.test(activeDocument.name)) {} else {
                // PROCESS DOCS CONTAINING ' copy'
                if (activeDocument.name.match(/ copy/)) {
                    var origDoc = activeDocument;
                    var docName = origDoc.name.replace(/ copy/, '');
                    origDoc.duplicate(docName, false);
                    origDoc.close(SaveOptions.DONOTSAVECHANGES);
                }
            }
        }
    }
}

 

  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

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 ,
Oct 09, 2022 Oct 09, 2022

Copy link to clipboard

Copied

Amazing thank you so much @Stephen_A_Marsh 

That worked perfectly, it has saved me a lot of time.  Much appreciated. 

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 ,
Oct 09, 2022 Oct 09, 2022

Copy link to clipboard

Copied

LATEST

@Joseph Brown 

 

You're welcome. The obvious extension to this is to automate saving the extracted 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