Copy link to clipboard
Copied
I would like to be able to write certain metadata for each image in a folder to a text file. I would like to see the filename, lens name, f/stop, shutter speed, focal length and ISO for each image.
I was a programmer at one time but that was a long time ago so I asked Gemini to write a Bridge script to access EXIF data. Once that was working I planned to further customze the script output, again with the hhlep of Gemini or Bing AI but it produces an error each time I try to open Bridge with the new script installed. After several rewrites, some of which had the return statement in dfifferent locations, that statement always prodiuced an error. The Javascript iis below:
+++++++++++++++++++++++++++++
function extractEXIFDataToText(folderPath, filename) {
// Build the ExifTool command
var exifToolCmd = "C:\Users\&&&&&\Downloads\exiftool -csv -overwrite_original -quiet " + folderPath + " -Model -CreateDate -ExposureTime -FNumber -ISOSpeed -FocalLength -WhiteBalance -Caption-Abstract -Headline -Description -Keywords >> " + filename;
// Execute the ExifTool command
var result = execute(exifToolCmd);
// Check for errors
if (result != 0) {
alert("Error running ExifTool: " + result);
} else {
alert("EXIF data written to " + filename);
}
}
// Get folder path from user
var folderPath = Folder.selectDialog("Select Folder Containing Images");
if (folderPath == null) {
alert("No folder selected!");
return;
}
// Get output filename from user
var filename = prompt("Enter filename for output text file (e.g., exif_data.txt)");
if (filename == null || filename.length === 0) {
alert("Please enter a filename!");
return;
}
// Call the extractEXIFDataToText function
extractEXIFDataToText(folderPath, filename);
++++++++++++++++++++++++
Bridge complains that the return statement on line 20 is outside the function (or words to that effect).
Can anybody help? Thanks in advance.
Here is an example using more specific entries from your list of requirements:
exiftool -System:FileName -XMP-aux:LensInfo -XMP-aux:Lens -XMP-exifEX:LensModel -XMP-exifEX:LensMake -Composite:LensID -ExifIFD:ExposureTime -Composite:ShutterSpeed -ExifIFD:FocalLength -ExifIFD:ISO -csv 'OS specific/path to the/input folder' > 'OS specific/path to the output/metadata file.csv'
The -Composite: group tag entries are derived from other metadata entries, simply remove any redundant tags as I have att
...Copy link to clipboard
Copied
You can start with taking a look at the following scripts:
https://prepression.blogspot.com/2016/08/extracting-metadata-to-csv.html
Although Bridge is probably the best tool for this task, Photoshop can also do the job.
The easiest way to do this sort of thing is using ExifTool as it is far easier than scripting. The following code -r recurses into all subfolders under the root directory and and writes -all metadata to -csv file:
exiftool -r -all -csv 'OS specific/path to the/input folder' > 'OS specific/path to the output/metadata file.csv'
You would replace the -all flag with the specific metadata entries that you require.
Note: If you use Windows, replace the single-straight quotes for double-straight quotes around paths that contain spaces.
Copy link to clipboard
Copied
Here is an example using more specific entries from your list of requirements:
exiftool -System:FileName -XMP-aux:LensInfo -XMP-aux:Lens -XMP-exifEX:LensModel -XMP-exifEX:LensMake -Composite:LensID -ExifIFD:ExposureTime -Composite:ShutterSpeed -ExifIFD:FocalLength -ExifIFD:ISO -csv 'OS specific/path to the/input folder' > 'OS specific/path to the output/metadata file.csv'
The -Composite: group tag entries are derived from other metadata entries, simply remove any redundant tags as I have attempted to provide some overlap/flexibility.
Copy link to clipboard
Copied
That is awesome! Thanks so much @Stephen Marsh
I think a better approach for my needs given what you've told me about EXIFtool, is to use Python to extract the data outside of either Photoshop or Bridge. EXIFtool is a beautiful app that I've used on occasion before but it's tricky to use it from the command prompt. You've spelled it all out for me.
Also, thanks for pointing me to those other resources and scripts. Iy'll take a while to digest everything LOL
Copy link to clipboard
Copied
That is awesome! Thanks so much @Stephen Marsh
You're welcome!
EXIFtool is a beautiful app that I've used on occasion before but it's tricky to use it from the command prompt.
Can you expand on this? There are various options, such as adding extra flags to only process specific file types, or to ignore certain named sub-directories when recursing into the parent/root directory. Both the Mac and Windows can have the file or folder dragged into the CLI to complete the path. There are scripts for Bridge and Photoshop to integrate ExifTool commands and there are OS integration possibilities as well as GUI front ends etc.
https://prepression.blogspot.com/2016/12/automator-diy-exiftool-gui-services.html
Copy link to clipboard
Copied
Well, foir example, I'm having trouble extracting the "Camera Model Name" from the EXIF data. I see that it's present becase when I run the following command:
C:\Users\xxx\Downloads\exiftool -a -u -g1 "C:\Users\Alask\Desktop\TEMP images\2024-05-14 Dorris Ranch\Bewick's Wren (Thryomanes bewickii) (IMG_8597).jpg" > "C:\Users\Alask\Desktop\EXIF-All.txt"
The output has a "section," fror lack of a better name, called IFD0. I've tried hal a dozen ways to extract it but nothing works. Here is the relevant section:
---- IFD0 ----
Make : Canon
Camera Model Name : Canon EOS R5
X Resolution : 300
Y Resolution : 300
Resolution Unit : inches
Software : Adobe Photoshop 2024 Windows
Modify Date : 2024-05-14T09:53:03-07:00
Artist : David James Swarthout
Copyright : Copyright 2020-2024 David James Swarthout, All Rights Reserved.
************************
What is the correct argument to use. Your example uses several "prefixes" to obtain certain values depending on which section they live in. I looked at the exiftool help but it did not answer my question. I'm confused.
Thanks for your help.
The comand line I'm using at the moment looks like this but it has had several iterations earlier, none of which produced the desired output.
C:\Users\Alask\Downloads\exiftool -System:FileName -Composite:CameraModelName -XMP-aux:LensInfo -XMP-aux:Lens -XMP-exifEX:LensModel -XMP-exifEX:LensMake -ExifIFD:ExposureTime -Composite:ShutterSpeed -Exi
Copy link to clipboard
Copied
-Exif:Model
Copy link to clipboard
Copied
That works. Thanks!
But how can I learn to make such queries on my own? I can't come and ask you every time I run into a problem.
Somewhere there must be a list of these data fields so one can ask in the correct format. Inspection of the output from this command "exiftool -a -u -g1 " I do not find a section called simply Exif. Where did the "-Exif:Model" parameter come from?
Copy link to clipboard
Copied
That works. Thanks!
But how can I learn to make such queries on my own? I can't come and ask you every time I run into a problem.
Somewhere there must be a list of these data fields so one can ask in the correct format. Inspection of the output from this command "exiftool -a -u -g1 " I do not find a section called simply Exif. Where did the "-Exif:Model" parameter come from?
By @Dave Swarthout
It depends on the source file being inspected.
My command is similar to yours:
exiftool -a -G1 -s -u
However, I also use the -s short tag flag. The key is that you are using the -u unknown flag.
Also note -G1 is different to -g1
The list of command line flags can be found here:
https://www.exiftool.org/exiftool_pod.html
Tag names here:
https://exiftool.org/TagNames/index.html
When I run the commands to inspect an ORF file, I may get the following output:
[IFD0] Model : E-520
[Olympus] CameraType2 : E-520
I then transform this output to use as input for the command that I am finally using:
-IFD0:Model
This is the explicit "long" version, using the -GROUP: prefix, followed by the TAG
I prefer this as it is unambiguous, if you know that there is no room for confusion, you could use the short version without the group prefix: -subject rather than using the full prefix+suffix -XMP-dc:Subject (XMP based keywords, as opposed to the old-style -IPTC:Keywords)
Copy link to clipboard
Copied
BTW, if you want an easier way to work with EXIFTool, I have a couple of Bridge scripts that integrate it with Bridge. That way you just select the image(s) and run the EXIFTool command.
https://www.dropbox.com/sh/mg817g9a9ymbasi/AADTmXUVxmFfM58bcyYE7yiwa?dl=0
Look in the Developmental folder. EXIFInfo displays your result in Bridge, you can experiment with different flags easily and copy/paste the results.
RunEXIFTool is designed as a way to enter commands if you don't need to see the output.
Copy link to clipboard
Copied
One final thing- EXIFTool operates on the actual file. If you have made adjustments to a RAW file and they are stored in a sidecar, you have to read the sidecar with EXIFTool to see them.
Copy link to clipboard
Copied
I'll give your Bridge Script a shot. Thank you.
Regarding your advice about RAW files: I plan only to do this for jpgs so the XMP issue won't bother me.
Copy link to clipboard
Copied
What is the correct argument to use. Your example uses several "prefixes" to obtain certain values depending on which section they live in. I looked at the exiftool help but it did not answer my question. I'm confused.
By @Dave Swarthout
I use the case-sensitive "group" name -G to help pinpoint and isolate explicit metadata, sometimes multiple tags may share the same name, so the group prefix is very useful.
-g[NUM...] (-groupHeadings) Organize output by tag group
-G[NUM...] (-groupNames) Print group name for each tag
https://www.exiftool.org/exiftool_pod.html
The Adobe forums aren't really the place for in-depth discussion of 3rd party tools, the ExifTool Forum is fantastic, you can learn a lot by reading and asking questions there:
https://exiftool.org/forum/index.php
Copy link to clipboard
Copied
Thank you. I installed your EXIFinfo tool and by using the named parameters as they appear in its window can tailor my output perfectly. I'm all set. My original question has been answered.
I agree that this lengthy discussion doesn't really belong here but I was desperate LOL
I will definitly check out the exiftool forum.
Again, many thanks for your patience and help.
Copy link to clipboard
Copied
You’re welcome. I brought up ExifTool as it is much easier to learn how to use than to learn how to script. What can be done in a minute in ExifTool may take hours in scripting. Even then, Adobe doesn't cover everything one wishes to do with scripting metadata.
Copy link to clipboard
Copied
Instead of the fluff, I'd love to see Adobe put effort into integrating third-party tools like EXIFTool, cloud services, ImageMagick, etc.
Copy link to clipboard
Copied
Adobe's XMP scripting is a PITA, frankly. I have written numerous scripts to work with metadata and in general, once you figure out the syntax, EXIFTool is a lot more powerful.
And forget AI for programming. Garbage in, garbage out.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now