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.
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
...
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).
With a regular expression ā
Find:
(.+)( copy)(\.[^\.]+$)
Replace:
$1$3
Copy link to clipboard
Copied
how would any app know which images have been cropped and/or straightened?
Copy link to clipboard
Copied
I posted this question in the Photoshop ecosystem message board, so Photoshop is the app I'm using.
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.
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
ohhhh. I thought they were manually doing the crop/straighten.
Copy link to clipboard
Copied
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);
}
}
}
}
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
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.
Copy link to clipboard
Copied
You're welcome. The obvious extension to this is to automate saving the extracted files.