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)

3 Likes