ExifTool Custom Columns

I would assume, that this procedure should be quite fast

Yep, but it's not. Here's a log from a test folder. It took 4.3 seconds to generate the files with ExifTool and then 15 seconds to copy the modify data:

ExifTool:  000:001 Processing 209 files in "D:\test\jpg" with ExifTool...
ExifTool:  000:002 - Cache (cacheFile.path): C:\Users\Alexander\ExifToolCache\D\test\jpg
ExifTool:  000:003 - Deleting cache
ExifTool:  000:524 - Generating files
ExifTool:  004:829 - Setting lastmodifieddate for files
ExifTool:  020:114 - Setting lastmodifieddate for cache
ExifTool:  020:188 ... done!

adding in exiftools.js the line

Remove time from the entry. Quicktime-MediaDuration is a string that confuses the script, which then returns the current date. I might add a new type to handle entries like that.

script seems not to work on network-shares

True, the current version blocks networks. To unblock, simply delete

if (item.path.drive == 0) return;

from the script. That's line 159 in the original version.

First of all, Your speed & quality answering is awsome! Thanks!


OK, I understand, ... but why do You set the lastmodiefieddate?
I thought of just read the FileModifyDate from movie-file and just read the FileCreateDate from the correspondig exif-metadata-cachefile - at that point, at which you want to open that for reading the cached exif-metadata. Not looking for that information inside, look for the desired date of the moviefile & cachefile itself.

with that check the first file above-left should not need a recreation of cachefile, because left one hasn't been altered after cache creation.
The second one has on the left side a FileModifyDate after the FileCreateDate on the right - possibly changed metadata, could lead to recreation of right fil
Shocking, the "Time" and "Network"-Thing works now like charme!


... also having an idea regarding special characters?

Found a solution for that "lastmodified"-thing... could be maybe nicer, but works! I didn't program in JS before...

Now, cachefile will automatically be actualised, if moviefile has been altered. Checking for maxCacheAge isn't needed anymore. And generating of new cachefiles will only be done for new files, not the whole folder anymore.

(Re)generating of cachefiles seems to be as fast as before, but recreating procedure (after maxCacheAge is reached) is significantally faster. This is remarkable for folders with many files in it.

Canged part of function onColumn(scripColData) as described below:


function OnColumn(scriptColData) {
    var item = scriptColData.item;
    if (item.is_dir) return;
    /* if (item.path.drive == 0) return; */

    var cacheFile = fsu.GetItem(cacheFolder + '\\' + String(item.realpath).replace(':', '') + '.txt');

    var cutOffDate = DOpus.Create().Date();
    cutOffDate.Sub(maxCacheAge, 'm'); // Current date minus ... minutes


// Inserted this IF for touching existing cacheFile only if mediafile has been altered AFTER generated cachefile and then only for that single file

	if (fsu.GetItem(cacheFile).modify<fsu.GetItem(item).modify) {
		cmd.RunCommand('Delete FORCE QUIET FILE="' + cacheFile + '"');
        Log('Processing altered File "' + item.name + '" in "' + item.path + '" with ExifTool...');
        var cmdLine = '"' + exeExifTool + '" -short -duplicates -unknown -groupNames -tab -textOut! "' + cacheFile.path + '\\%f.%e.txt" -extension "*" "' + String(item).replace(/\\$/, '') +  '"'; 
        wsh.Run(cmdLine, 0, true);
        cmd.RunCommand('SetAttr FILE="' + cacheFile.path + '" META "lastmodifieddate:' + DOpus.Create().Date().Format('D#yyyy-MM-dd T#HH:mm:ss') + '"');
        Log('... done!');
    }

// changed following exiftool command for ignoring maxCacheAge and then only processing single files instead of the whole folder in one step

    if (!fsu.Exists(cacheFile))  {/* || fsu.GetItem(cacheFile.path).modify.Compare(cutOffDate) < 0) */
        Log('Processing new File "' + item.name + '" in "' + item.path + '" with ExifTool...');
        var cmdLine = '"' + exeExifTool + '" -short -duplicates -unknown -groupNames -tab -textOut! "' + cacheFile.path + '\\%f.%e.txt" -extension "*" "' + String(item).replace(/\\$/, '') +  '"'; 
        wsh.Run(cmdLine, 0, true);
        cmd.RunCommand('SetAttr FILE="' + cacheFile.path + '" META "lastmodifieddate:' + DOpus.Create().Date().Format('D#yyyy-MM-dd T#HH:mm:ss') +  '"');
        Log('... done!');
    }

// nothing changed afterwards comparing to original script ...

    if (!fsu.Exists(cacheFile)) {
        Log('*** Error: cache file could not be created! ***');
        Log('item:      ' + item);
        Log('cacheFile: ' + cacheFile);
        Log('');
        Log('cmdLine:');
        Log(cmdLine);
        Log('');
        return;
    }

so for me only the part of special letters like Ä or ß are still up... :wink: and, as I personally only need "quicktime" metadata, I will look for a possibility to filter exiftool output for that.... Any idea?

1 Like

Here's a new version with the following changes:

  • UTF8 encoded metadata (Umlauts etc.) is displayed properly. Almost everywhere... who can spot the exceptions?
  • Cache will be rebuilt, if the item's modify date is more current than the cache folder's
  • Cache will be rebuilt, if the flag onAnyChange is true and the item's modify date differs from the cache file's (slower because of enhanced record keeping)
  • Logging reveals more info

Any testing and feedback is welcome. I'll update the main post after a bit of waiting time.

ColumnExifTool.js.txt (2022-06-14)

3 Likes

Works very fine as far as I see... with one exception...

The metadata itself will be displayed correctly with 'Umlaute', but the columntitle won't:
grafik
This should be 'Auflösung'
new DefineColumn('Composite', 'ImageSize', '', 'Auflösung', 'Auflösung', '', '', ''),

And, two questions:

If one single file is being updatet, the single cachefile will be re-done. But all modify dates of cachefiles inside that folder will be raised. Why?
I tried a "comment-out" for all "SetATTR"-lines, but it still will be altered...

Is it possible to implement a function like a blacklist for filetypes shouldn't be cached?

Thanks for your great support!

Because ExifTool processes the entire folder. Until yesterday, that is :sunglasses:

Yes :slight_smile:

1 Like

Here's a new version with the following changes:

  • Display of UTF8 encoded stuff is even better, but still not perfect.
  • Now cache files will only be generated or renewed for files that are visible in the tab. Files that are hidden by a filter or are siblings of files in collections are skipped.
  • The set extToIgnore can be filled with extensions the script should always ignore.
  • Cache will be rebuilt, if the item's modify date is more current than the cache file's (was: folder).
  • Removed the onAnyChange flag
  • Removed the maxCacheAge option
  • New syntax for column definition

The column definition syntax has changed. If you want to copy your modifications to the new script,

replace

new DefineColumn

with

exifColumns.push_back(DefineColumn

and

'),

with

'));

and add a ); to the last entry.

Confusing? You'll know it when you see it :wink:

ColumnExifTool.js.txt (2022-06-20)

Any testing and feedback is still welcome :slight_smile:

And how do I get the utf8 decoding/encoding for the columns right?

1 Like

Thank you. I am grateful and excited to try the new version, but I keep getting an error message when I add the file:
image

The only thing I changed in the file was the path to Exiftool on my system, which I copied and pasted from the file I previously used that did not have errors. I checked that line carefully to make it was identical.

image
I don't know how to determine what the error is.
Can someone please help?

There's a ' or " missing. Can you show us the line(s) you modified?

Thank you Leo. Because of your comment, I looked at the punctuation, and I had a curly/curved single quote mark. I replaced it with a straight one and now it works.

Works perfectly, lxp! Thanks for Your great work!

last question... would it be a big job to give your script also an option for a whitelist, something like ExtToUse ?

Nope.

New version that allows files to either get selected or ignored based on their extensions.

How to use:

  1. Define a set of extensions specialExt.

  2. Set filterExt to determine how these extensions get handled:

    • positive value: the script will only select files with a special extension
    • zero: the script will process all files
    • negative value: the script will ignore files with a special extension

To update the previous version, simply copy the stringset (old name extToIgnore) and all lines starting with exifColumns.push_back to the new script.

ColumnExifTool.js.txt (2022-06-27b)

5 Likes

P E R F E C T

Great Job! You did it!

I would wish my external "programmers" at company would work just a little bit like You do.

Many Thanks!!

This script is very helpful to me, but not all metadata fields with dates are displaying those dates.

Because adding a Date Taken to a photo with Directory Opus results in that date being added to the Exif DateTimeOriginal field only, I made a button with a command to copy the Exif DateTimeOriginal to other date fields. When I use that button/command, I can see (using ExifToolGUI and another application) that the dates have been copied to the fields I specified, but they are not displaying in Directory Opus. I refreshed, closed and re-opened Directory Opus, and the dates are still not being displayed. I even re-started my PC just to be sure.
The fields that are not displaying a date that IS present are: Exif CreateDate and XMP CreateDate:

Dates can be seen in those fields in ExifTool GUI:

I am confident that the dates are in the metadata, so I am not too concerned that the dates aren't visible. However, I thought I should let you know.

The recent changes broke the script's ability to work in Rename commands.

This version fixes this.

ColumnExifTool.js.txt (2022-09-04)

1 Like

Changelog

  • Better performance when called from Find and Rename commands/panel
  • Files can be included/excluded in/from processing via Opus' wildcard system, instead of just by extension
  • Support for column type double which should be used for all duration type fields (don't use time)
  • Expanded logging. Worth checking if you think something's wrong/slow/stalled
  • Post-processing for some fields for improved compatibility (Quicktime, Long manufacturer model names)
  • A bit of housekeeping under the hood

ColumnExifTool.js.txt 2023-02-28

Things to do after downloading:

  • Adjust the path to exiftool.exe
  • If you have modified column definitions, you need to replace push_back(DefineColumn( with push_back(GetColumnMap( after copying them to the new version
  • If you used the specialExt feature, you need to recreate it as a wildcard. Should be easy, examples are in the script.
4 Likes

I've tried about 16 variations on the path but am still getting "no exif tool found"

Is there something missing from what I've done?

// -- Adjust to your system. Copy the path to exiftool.exe with 'Edit - Copy Other - Copy Full Pathnames (Double Backslashes)'
var exeExifTool = fsu.Resolve('C:\\exiftool\\exiftool.exe');

// -- Adjust to your preferences. Use double backslashes.
var cacheFolder = fsu.Resolve('/profile\\C:\\Users\\bri\\ExifToolCache');

Where is your exiftool.exe?

Use either

var cacheFolder = fsu.Resolve('/profile\\ExifToolCache');

or

var cacheFolder = fsu.Resolve('C:\\Users\\bri\\ExifToolCache');

Why?