var cmd = DOpus.Create().Command(); var fsu = DOpus.FSUtil(); var fso = new ActiveXObject('Scripting.FileSystemObject'); var wsh = new ActiveXObject('WScript.Shell'); var exifTags = DOpus.Create().Map(); var exeExifTool = fsu.Resolve('/bin\\exiftool\\exiftool.exe'); // -- Adjust to your system var cacheFolder = fsu.Resolve('/profile\\ExifToolCache'); // -- Adjust to your preferences var maxCacheAge = 60; // Rebuild cache if older than ... minutes -- Adjust to your preferences var log = true; // -- Adjust to your preferences. Set to false if you don't want any logging // Column definitions go here. Make sure there is no comma in the last line before the closing bracket. // group, tag: reference for ExifTool (mandatory) // name, label, header: adjust to your preferences (optional) // justify: like Opus standard for columns (optional) // type: datetime, date, time, number. String, if left empty (optional) // defaultValue: value, if no tag is found via ExifTool (optional) // group, tag, name, label, header, defaultValue, justify, type var exifColumns = [ new DefineColumn('Canon', 'CanonExposureMode', '', '', '', '', '', ''), new DefineColumn('Canon', 'FocusMode', '', '', '', '', '', ''), new DefineColumn('Canon', 'MeteringMode', '', '', '', '', '', ''), new DefineColumn('Canon', 'NumAFPoints', '', '', '', '', '', 'number'), new DefineColumn('Canon', 'OneShotAFRelease', '', '', '', '', '', ''), new DefineColumn('Canon', 'ValidAFPoints', '', '', '', '', '', ''), new DefineColumn('Composite', 'Aperture', '', '', '', '', '', 'number'), new DefineColumn('Composite', 'AvgBitrate', '', '', '', '', '', ''), new DefineColumn('Composite', 'CircleOfConfusion', '', '', '', '', '', ''), new DefineColumn('Composite', 'FOV', '', '', '', '', '', ''), new DefineColumn('Composite', 'HyperfocalDistance', '', '', '', '', '', ''), new DefineColumn('Composite', 'ImageSize', '', '', '', '', '', ''), new DefineColumn('Composite', 'LensID', '', '', '', '', '', ''), new DefineColumn('Composite', 'LightValue', '', '', '', '', '', ''), new DefineColumn('Composite', 'Megapixels', '', '', '', '', '', ''), new DefineColumn('Composite', 'Rotation', '', '', '', '', '', 'number'), new DefineColumn('Composite', 'ShutterSpeed', '', '', '', '', '', ''), new DefineColumn('Composite', 'SubSecCreateDate', '', '', '', '', '', 'datetime'), new DefineColumn('Composite', 'SubSecDateTimeOriginal', 'SSDTO', 'SSDTO', 'SSDTO', '', '', 'datetime'), new DefineColumn('EXE', 'CompanyName', '', '', '', '', '', ''), new DefineColumn('EXE', 'MachineType', '', '', '', '', '', ''), new DefineColumn('EXE', 'SubsystemVersion', '', '', '', '', '', ''), new DefineColumn('EXE', 'TimeStamp', '', '', '', '', '', 'datetime'), new DefineColumn('EXIF', 'CreateDate', '', '', '', '', '', 'datetime'), new DefineColumn('EXIF', 'DateTimeOriginal', '', '', '', '', '', 'datetime'), new DefineColumn('EXIF', 'Model', '', '', '', '', '', ''), new DefineColumn('EXIF', 'Orientation', '', '', '', '', '', ''), new DefineColumn('ExifIFD', 'DateTimeOriginal', '', '', '', '', '', 'datetime'), new DefineColumn('File', 'FileAccessDate', '', '', '', '', '', 'datetime'), new DefineColumn('File', 'FileCreateDate', '', '', '', '', '', 'datetime'), new DefineColumn('File', 'FileModifyDate', '', '', '', '', '', 'datetime'), new DefineColumn('File', 'FileTypeExtension', '', '', '', '', '', ''), new DefineColumn('H264', 'ApertureSetting', '', '', '', '', '', ''), new DefineColumn('H264', 'DateTimeOriginal', 'Date MTS', 'Date MTS', 'Date MTS', '', '', 'datetime'), new DefineColumn('H264', 'ExposureProgram', '', '', '', '', '', ''), new DefineColumn('H264', 'ExposureTime', '', '', '', '', '', ''), new DefineColumn('H264', 'FNumber', '', '', '', '', '', 'number'), new DefineColumn('H264', 'Focus', '', '', '', '', '', ''), new DefineColumn('H264', 'Gain', '', '', '', '', '', ''), new DefineColumn('H264', 'ImageHeight', '', '', '', '', '', ''), new DefineColumn('H264', 'ImageStabilization', '', '', '', '', '', ''), new DefineColumn('H264', 'ImageWidth', '', '', '', '', '', ''), new DefineColumn('H264', 'Model', '', '', '', '', '', ''), new DefineColumn('M2TS', 'Duration', '', '', '', '', '', 'time'), new DefineColumn('M2TS', 'VideoStreamType', '', '', '', '', '', ''), new DefineColumn('MakerNotes', 'CameraOrientation', '', '', '', '', '', ''), new DefineColumn('MakerNotes', 'ShutterCount', 'SSC', 'SSC', 'SSC', '', '', 'number'), new DefineColumn('Matroska', 'DateTimeOriginal', '', '', '', '', '', ''), new DefineColumn('Matroska', 'DisplayHeight', '', '', '', '', '', 'number'), new DefineColumn('Matroska', 'DisplayWidth', '', '', '', '', '', 'number'), new DefineColumn('Matroska', 'Duration', 'MatDur', '', '', '', '', 'time'), new DefineColumn('Matroska', 'ImageHeight', '', '', '', '', '', 'number'), new DefineColumn('Matroska', 'ImageWidth', '', '', '', '', '', 'number'), new DefineColumn('Matroska', 'TrackNumber', '', '', '', '', 'number', ''), new DefineColumn('PDF', 'CreateDate', '', '', '', '', '', 'datetime'), new DefineColumn('PDF', 'Creator', '', '', '', '', '', ''), new DefineColumn('PDF', 'ModifyDate', '', '', '', '', '', 'datetime'), new DefineColumn('PDF', 'PageCount', '', '', '', '', '', 'number'), new DefineColumn('PDF', 'Producer', '', '', '', '', '', ''), new DefineColumn('PDF', 'Title', '', '', '', 'Move on. Nothing to see here but the PDF default value', 'left', ''), new DefineColumn('QuickTime', 'AudioAvgBitrate', '', '', '', '', '', ''), new DefineColumn('QuickTime', 'CompressorID', '', '', '', '', '', ''), new DefineColumn('QuickTime', 'CreateDate', '', '', '', '', '', 'datetime'), new DefineColumn('QuickTime', 'CreationDate', '', '', '', '', '', 'datetime'), new DefineColumn('QuickTime', 'Duration', '', '', '', '', '', 'time'), new DefineColumn('QuickTime', 'MediaCreateDate', '', '', '', '', '', 'datetime'), new DefineColumn('QuickTime', 'MediaDuration', '', '', '', '', '', 'time'), new DefineColumn('QuickTime', 'MediaModifyDate', '', '', '', '', '', 'datetime'), new DefineColumn('QuickTime', 'Model', '', '', '', '', '', ''), new DefineColumn('QuickTime', 'ModifyDate', '', '', '', '', '', 'datetime'), new DefineColumn('QuickTime', 'TrackCreateDate', '', '', '', '', '', ''), new DefineColumn('QuickTime', 'TrackModifyDate', '', '', '', '', '', ''), new DefineColumn('QuickTime', 'VideoAvgBitrate', '', '', '', '', '', ''), new DefineColumn('QuickTime', 'VideoAvgFrameRate', '', '', '', '', '', ''), new DefineColumn('QuickTime', 'VideoSize', '', '', '', '', '', ''), new DefineColumn('Sony', 'FocusMode', '', '', '', '', '', ''), new DefineColumn('XML', 'CreationDateValue', '', '', '', '', '', 'datetime'), new DefineColumn('XML', 'DeviceManufacturer', '', '', '', '', '', ''), new DefineColumn('XML', 'DeviceModelName', '', '', '', '', '', ''), new DefineColumn('XML', 'DeviceSerialNo', '', '', '', '', '', ''), new DefineColumn('XML', 'VideoFormatVideoFrameCaptureFps', '', '', '', '', '', ''), new DefineColumn('XMP', 'Contributor', '', '', '', '', '', ''), new DefineColumn('XMP', 'CreateDate', '', '', '', '', '', 'datetime'), new DefineColumn('XMP', 'Creator', '', '', '', '', '', ''), new DefineColumn('XMP', 'CreatorTool', '', '', '', '', '', ''), new DefineColumn('XMP', 'Date', '', '', '', '', '', 'datetime'), new DefineColumn('XMP', 'DateCreated', '', '', '', '', '', 'datetime'), new DefineColumn('XMP', 'Description', '', '', '', '', '', ''), new DefineColumn('XMP', 'Format', '', '', '', '', '', ''), new DefineColumn('XMP', 'MetadataDate', '', '', '', '', '', 'datetime'), new DefineColumn('XMP', 'ModifyDate', '', '', '', '', '', 'datetime'), new DefineColumn('XMP', 'Producer', '', '', '', '', '', ''), new DefineColumn('XMP', 'Title', '', '', '', '', 'left', ''), new DefineColumn('XMP', 'XMPToolkit', '', '', '', '', '', '') ]; function DefineColumn(group, tag, name, label, header, defaultValue, justify, type) { this.group = group; this.tag = tag; var tmp = (group + '-' + tag); this.name = name == '' ? tmp : name; this.label = label == '' ? tmp : label; this.header = header == '' ? tmp : header; this.defaultValue = defaultValue; this.justify = justify; this.type = type; } function OnInit(initData) { initData.name = 'ExifTool'; initData.desc = 'Provide columns for tags read via exiftool.exe'; initData.version = '2021-07-17'; initData.url = 'https://resource.dopus.com'; initData.default_enable = true; cmd.RunCommand('CreateFolder NAME="' + cacheFolder + '"'); Log('exeExifTool: ' + exeExifTool + (fsu.Exists(exeExifTool) ? ' - OK' : ' - not found!')); Log('cacheFolder: ' + cacheFolder + (fsu.Exists(cacheFolder) ? ' - OK' : ' - not found!')); } function OnAddColumns(AddColData) { for (var i = 0; i < exifColumns.length; ++i) { var column = exifColumns[i]; var col = AddColData.AddColumn(); col.multicol = true; col.name = column.name; col.label = column.label; col.header = column.header; col.justify = column.justify; col.type = column.type; col.method = 'OnColumn'; } } 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 if (!fsu.Exists(cacheFile) || fsu.GetItem(cacheFile.path).modify.Compare(cutOffDate) < 0) { Log('Processing ' + fso.GetFolder(item.path).files.count + ' files in "' + item.path + '" with ExifTool...'); var cmdLine = '"' + exeExifTool + '" -short -duplicates -unknown -groupNames -tab -textOut! "' + cacheFile.path + '\\%f.%e.txt" -extension "*" "' + String(item.path).replace(/\\$/, '') + '"'; // ExifTool doesn't like the trailing slashes item.path produces for root folders like C:\ 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!'); } 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; } exifTags.clear(); var tf = fso.OpenTextFile(cacheFile, 1); while (!tf.AtEndOfStream) { var line = tf.ReadLine().split('\t'); var group = line[0]; var tag = line[1]; var value = line[2]; var key = group + '-' + tag; exifTags(key) = value; } tf.Close(); for (var i = 0; i < exifColumns.length; ++i) { var column = exifColumns[i]; var key = column.group + '-' + column.tag; var value = exifTags.exists(key) ? exifTags(key) : column.defaultValue; if (value != '') { if (column.type == 'datetime' || column.type == 'date' || column.type == 'time') { value = DOpus.Create().Date(value.replace(/:/g, '')); } else if (column.type == 'number') { value = Number(value); } } scriptColData.columns(column.name).value = value; } } function Log(str) { if (log) DOpus.Output(str); }