Skip to main content
Participant
September 19, 2018
Question

Rename file, delete "_abc1234" and save to processed folder

  • September 19, 2018
  • 1 reply
  • 3944 views

Hey there,

sadly i´m still new in the world of PS scripting but i´ve already fount so much useful scripts, tips and ideas here!

Currently i´m looking für a script (which sadly exceeds my knowledge) to rename my files and save them into a new "processec" folder at the same place.

The files i´m going to work on are named like: §BI00337684§_HPK1155.JPG or §AN00550282§_CHJ3942.JPG or §AD00093642§_IMG0023.JPG

It would be so cool and so much work saving if a script can delet everything after the "_" and the "_" itself.

Maybe somebody could help me...

Thanks in advance, Chris from austria!!

This topic has been closed for replies.

1 reply

Stephen Marsh
Community Expert
Community Expert
September 19, 2018

So you have a JPEG file open that has been edited.

What happens to this file file when the script  renames etc?

Does the original file stay open with the renamed file saved as a copy in the backgroun?

Or does the edited file save as with the new name and remain open, leaving the original as per the last save state?

Can you list step by step what should happen?

BardiochAuthor
Participant
September 19, 2018

Hey Stephen,

i´m going to use this script in an PS action.

1. create a copy of the file

2. save it (without the _abc1234) into a "processed" folder

3. remain open the processed file and leave the original as it was

4. PS action with some standard stuff

5. now i will work on each file individually and save it

OH, i made a mistake... my files look like   "1ABCD_§BI00337684§_HPK1155.JPG"   sorry...

Thanks!!

Stephen Marsh
Community Expert
Community Expert
September 20, 2018

Hi Chris,

Let me start by saying that I can’t write script code, on a good day I can hack/change an existing script… and on a really good day I can combine parts of different scripts together to make a new script or perhaps create a few lines of script from scratch.

The code that I have knocked together is a work on progress, I am not 100% happy with it but it get’s some of the job done and it is a minor miracle that I have made it this far!

What the script does:

* Duplicates the original document, removing the underscore and alphanumeric directly before the filename extension from the duplicate’s filename. This step should ideally have error checking code in case the source file has not been saved, however that is a little advanced for me at this stage, so the presumption is a saved file as the source

* Returns to the original open document, closes without saving any changes – this step presumes that you simply opened the file and did not do anything and don’t wish to save anything if something was done

* Returns to the duplicated document

* Creates a new folder titled “Processed” in the same folder as the original document

What the script doesn't do:

You then have to manually save the file and format into the processed folder, as I’m still trying to figure out how to save the file into the new directory.

Questions:

Is the input file always a JPEG? Do you always wish to save a JPEG to the processed folder? If your action creates any layers, will they be flattened before you save over the processed file?