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

Implementing a script to edit metadata in RAW files

New Here ,
Nov 22, 2024 Nov 22, 2024

Copy link to clipboard

Copied

Hello everyone,

I'm new to this group and not expert at all in using Bridge. I have a requirement here, but also some doubts, so I would like to receive some hints… here are the facts:

 

Requirement

Almost always, after generating a .jpg (or .png) file at the end of a typical Photoshop processing section, I rename it, replacing the name automatically generated by the camera (essentially, an abstract progressive code) with a self-explanatory one (such as: "maple in autumn.jpg"). By doing so, however, I lose the link between the .jpg file and the RAW from which it was derived.

Sometimes, however, I have happened to "rethink" the result of an elaboration and therefore want to redo it to modify it accordingly, but, having lost the link between the jpg and the RAW, I have to remember it by myself or waste time trying to recover the "right" RAW (perhaps by dint of attempts between several RAWs that are almost identical... I know that I could also save the processed file in Photoshop's .psd format, but usually these files are very large and my disk is already almost full...)

 

Solution

Implement a script to be launched in the directory of the computer where the RAW files were saved as soon as they were downloaded from the camera, which performs these operations:

  • for each of the RAW files present:
    • reads the name of the file
    • reads the shooting date in the Exif data inside the file
    • creates a unique key, such as: "filename|data" (for example "_JK40511.ORF|20241121")
    • writes the newly created key in a record, normally neither used nor automatically rewritten, among the many available in the metadata.

In this way, each jpg file generated by Photoshop, for example, will contain among its metadata the name (in the key made unique by the presence of the shooting date, too) of the original RAW file.

 

Possible issues

  • in which language should I write the script? My Bridge is installed on a mac, where Script Editor runs. But can this language access in R/W the metadata of an image file?
  • actually I do not use .RAW files but .ORF or .RW2 (the proprietary RAW formats of Olympus and Panasonic respectively): would a similar script work on both types of files without modifications or should it have to be customized for each format?

This is what I thought, but I wouldn't be surprised if there were other possible solutions, maybe much simpler or even "free" (in the sense that they are already implemented in Bridge and ready to use, but I don't even know that they exist...). This is why I tried to ask here, sure to meet someone much more expert and skilled about these subjects.

 

Thanks in advance,

Ivan (Milan, Italy)

TOPICS
Metadata , Scripting

Views

135

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 ,
Nov 22, 2024 Nov 22, 2024

Copy link to clipboard

Copied

@ivan_1959 

 

For scripting Bridge, your only choice is ExtendScript.

 

You may not need a script, Bridge's Batch Rename Tool can embed the filename in the XMP "Preserved Filename" metadata and it is simple enough to rename the file to the same name (for example, finding and replacing the dot/period .  character with itself) to force this metadata entry. You may also have the original filename already included in proprietary metadata. This doesn't include the pipe | character and date/time info that you mentioned, however, I don't know how critical that is or if it is untouched in another field.

 

Adobe Camera Raw doesn't modify the original RAW files, so any metadata edits or other processing instructions are written to XMP sidecar files, which are just plain text files with the same name as the raw file (OLY1234.ORF & OLY1234.XMP) etc.

 

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 ,
Nov 23, 2024 Nov 23, 2024

Copy link to clipboard

Copied

Hi Stephen,

 

thank you very much for your hints. I did several tests and was near to giving up, when perhaps I managed to find a solution, please check if it sounds well to you: I discovered there is a free tool to read/write/modify the metadata: it is ExifTool, a reader/editor only available in command line form (check the related page: exiftool_dot_org , where you can download the version you need). Before reading how to write values in the metadata records, I tried to install and do some testing with the tool. Well, it has plenty of options, but if you run it giving as an argument a graphic file (e.g. just an ORF or a JPG, there are many supported formats) it returns the values of all the metadata records (a huge number!).

At first I was thinking that there were no links between the JPG and the ORF, but eventually I tried to do something more ordered. Here is the test I performed:

 

Test performed:

  • taken a random ORF file and renamed to: _sample_raw_file.ORF
  • made a random change in Photoshop and saved as: _sample_derived_jpg_file.jpg
  • launched ExifTool with the two files as argument (in separate runs) and saved the outputs to exif_orf.txt and exif_jpg.txt
  • brought the results to excel after replacing the separator ":" with a "tab"
  • searched, for each object's records, for the empty fields

 

Result:

_sample_raw_file.ORF consists of 246 records, of which 6 are empty:

  • Image Description
  • Extender Serial Number
  • Extender Model
  • Conversion Lens
  • Flash Serial Number
  • User Comment

_sample_derived_jpg_file.jpg consists of 295 records, of which 2 are empty:

  • URL List
  • Device Model

 

It seemed I had no chances: the two types of files have different metadata, and there isn't a record which has the same name and is empty… when I had an idea: I checked if the name of the original ORF file is written somewhere in the JPG file derived from it, and… BINGO! I found that the "Slices group Name" record of the JPG metadata reports the original ORF name!

 

This doesn't mean that everything is fine and this is valid in every case, but I think I'm on the right way!

For what concerns using a script, probably there's no reason at this point: my requirement is needed only a few times, so there's no need to automate things, because JPG metadata already contain the original ORF (RAW) file name. If I forget it, I only have to run ExifTool and search for the record above mentioned: it contains what I'm looking for!

What do you think?

 

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 ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

@ivan_1959 - Yes, I am familiar with ExifTool, if you search the forum you'll find a few posts where I have shared various commands to achieve things that require a lot of complex scripting in Bridge.

 

If you Save As from Photoshop then the slices metadata will be retained, however it will not be if using Export As or Save for Web (Legacy).

 

It would still be a good idea to either use Batch Rename to set the current filename in the Preserved Filename XMP metadata or copy the slices metadata to the Preserved Filename metadata as backup.

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 ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

@Stephen_A_Marsh - Thank you for these hints, I'll try to search the forum and check examples: e.g. it would be better to implement a smart use of Exiftool just to retrieve only the relevant value instead of returning the whole metadata, and then go and search manually for that particular record.


For what concerns the difference between Save As and Export, good to know, but I always use the first one (in fact, I was able to find the original ORF file name in the JPG metadata, just because I created it using the Save As option).

Writing in the XMP metadata: good idea, but I think that my need to retrieve the original ORF file name don't occur so much frequently, so I can live also with a less sophisticated method.

 

Thanks again,

Ivan (Milan, Italy)

 

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
Advisor ,
Nov 26, 2024 Nov 26, 2024

Copy link to clipboard

Copied

LATEST

Why not simply rename the Raw file BEFORE you generate a jpeg then both will have the same name? That is what I do with my many thousands of images so there is never a problem should I wish to find the original Raw.

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