Creating Commands With Exiftool to Select Files

You'll probably get help faster by asking for assistance over on the exiftool forum. I've reached out there a couple of times and they are extremely helpful.

You may not have the corresponding metadata columns visible in details mode? This will force DOpus to load the metadata in the columns and may take some time depending on how many files you're dealing with... My guess is the columns are not visible and therefore the metadata isn't read into memory at the time you issue the select command. This could cause a 'not responding' situation because it's loading the metadata after you run the select command. Either way you will have to wait for the metadata the get read one way or another.

In other words... make visible corresponding metadata columns, wait for the metadata to load, then try the select command.

I'd need to check how to use the custom columns to select empty fields.

If your overall goal is to apply tagging operations only to files that meet certain conditions ("DateTimeOriginal is empty"), you can do this directly on the ExifTool command line:

exiftool.exe -if "not $DateTimeOriginal" "-DateTimeOriginal<ModifyDate" -@ {allfilepath|filem}
1 Like

Thank you. My goal is to find, select, and move photos without an Exif DateTimeOriginal to another folder, and recreate the folder structure. Recreating folder structure is very important to my work because folder names often include dates or date clues - like "Halloween 2013", and I need to preserve that information. The option to recreate folder structure is one of my favorite things about DOpus.

As a professional photo organizer, I gather files from my client's EHDs, computers, CDs, cloud storage, etc. Collection sizes I work with range from 60,000 to 8 million files. The collections always contain photos that have been scanned or have been stripped of their Exif date metadata.

I tried your code in the Exiftool command line and got the error message "...is not recognized as an internal or external command, operable program or batch file."

Using your code in the command editor, I tried to create a command a couple of different ways (using my other other working ExifTool commands in DOpus as a guide) but the command line screen just flashes on then closes.

I should have said this in my original post: Ideally, I want a button.
I use exiftool commands in ExifToolGUI, and have created some buttons in DOpus that work well but I have not yet figured out the key to what is needed for me to reliably get those commands to work as a button in DOpus.

Thank you for your suggestion.
I should have specified in my original post that I want a button I can use in DOpus.
I have used ExifTool commands in ExifTool and in ExifToolGUI, but when creating a button in DOpus, one cannot simply enter the ExifTool command in the command Editor (with the MS-DOS option selected).

While I'm I'm confident I'd get help in the by posting in the forum (I am a member) I still need help making it work as a button in DOpus.

Thank you yonder. I have tried many ways of finding and selecting files with no Exif DTO. I DO have Exif columns visible. Here are the various methods I have used to do this task:

Method 1:
I use a folder format I have set up that displays several different Exif columns, including Exif DateTimeOriginal (Exif DTO), so I DO have that column visible. I sort and group by the Exif DTO column, and wait. And wait. I cannot tell when the sorting is done, because the blue circle keeps on spinning.
There are times when I have stopped waiting and selected and separated out the files without an Exif DTO, but then later in the project, I find more! It's just not dependable.

Method 2:
As described in my original post, but I'll provide more detail:
I open a folder (usually huge folders with tens of thousands of photos) in Flat View (no folders) and select a folder format that I have set up to display a few columns, including Exif DTO. For the same reason I described above, it's hard to tell when all metadata has finished loading.
I click a button I created based on a filter, and then wait.... and wait....While I'm waiting, I cannot move DOpus to another monitor, and I cannot open a new lister.

Method 3:
I use 'Find' and filter for photos (Images file type group) with and Exif DTO before 1900. There is no option to filter for photos with no Exif DTO. Using this filter often generates some false result - photos that do have intact Exif date metadata! When the results are displayed, they are in a collection. One cannot select files in a collection and move them while recreating folder structure. I do have a command to move files from a collection and recreate folder structure, but that adds a few steps to the process to set up the destination.

Ok, let's focus on this aspect.

If you use the Find command to look for images without DTO, you might make the script analyze a lot more files than you were expecting and potentially some files that really take a long time, e.g. .gpx.

The first step towards a solution would be to look at the script logs in the utility panel. They should give you a good overview of what's going on. The log is also available as /dopusdata\Logs\Script Output.txt. If you send me a zipped copy via PM, I'll be happy to have a look.

Thank you for your help. I have not used the Find command from the drop-down list of commands in the Command Editor.
I have used Find in the Utility Panel.
I only look for photos with no Exif DTO after I have separated out all other file types, so I am using Find in folders with JPGs only.
Might the script logs still provide some clues?

This script will scroll the files being processed in the Other Logs panel so you can see the progress. Then select the files with no DTO. Also if DOpus hangs while reading any particular file it will freeze the output on the problem file in Other Logs.

function OnClick(data)
{
	var cmd = data.func.command;
	var files = data.func.sourcetab.files;
	cmd.RunCommand("Set UTILITY=otherlog");
	cmd.RunCommand("Select NONE");
	cmd.deselect = false;
	cmd.ClearFiles();

	for (var i = 0; i < files.count; i++)
	{
		if (files(i).metadata == "image")
		{
			var digits = files.count.toString().length;
			var date = files(i).metadata.image.datetaken;
			if (date == null)
			{
				DOpus.Output(pad(i + 1, digits) + "/" + files.count + 
				": No DTO              " + files(i).name);
				cmd.AddFile(files(i));
			}
			else
			{
				DOpus.Output(pad(i + 1, digits) + "/" + files.count + ": " + 
				formatDate(date) + " " + files(i).name);
			}
		}
	}

	if (cmd.filecount > 0)
		cmd.RunCommand("Select FROMSCRIPT");
}

function pad(n, z) {return Array(Math.max(z - String(n).length + 1, 0)).join(0) + n;}
function formatDate(date) {return date.Format("D#MM-dd-yyyy T#HH:mm:ss");}


I tested this on about 7600 images and it took 26 seconds to complete.

Correction to my last post that I can no longer edit, so creating a new post...

Example:
purple.jpg
orange.jpg <<<<< DOpus hangs on this file in other logs

Then refer to the actual list of files to get the problem file, that would be the next file in the list of files.

purple.jpg
orange.jpg
green.jpg <<<<< Potential problem file
blue.jpg

Updated script fix... I moved the line cmd.RunCommand("Select NONE"); as this could cause problems if you select files after script is executed.

function OnClick(data)
{
	var cmd = data.func.command;
	var files = data.func.sourcetab.files;
	cmd.RunCommand("Set UTILITY=otherlog");
	cmd.deselect = false;
	cmd.ClearFiles();

	for (var i = 0; i < files.count; i++)
	{
		if (files(i).metadata == "image")
		{
			var digits = files.count.toString().length;
			var date = files(i).metadata.image.datetaken;
			if (date == null)
			{
				DOpus.Output(pad(i + 1, digits) + "/" + files.count + 
				": No DTO              " + files(i).name);
				cmd.AddFile(files(i));
			}
			else
			{
				DOpus.Output(pad(i + 1, digits) + "/" + files.count + ": " + 
				formatDate(date) + " " + files(i).name);
			}
		}
	}

	if (cmd.filecount > 0)
	{
		cmd.RunCommand("Select NONE");
		cmd.RunCommand("Select FROMSCRIPT");
	}
}

function pad(n, z) {return Array(Math.max(z - String(n).length + 1, 0)).join(0) + n;}
function formatDate(date) {return date.Format("D#MM-dd-yyyy T#HH:mm:ss");}

Thank you yonder.
I have not yet tried your script, but I did notice 'datetaken' in it, and not Exif DateTimeOriginal.
In the collections I work with, I typically find a lot of photos that do have a Date Taken, but no Exif DateTimeOriginal. Those photos are most often scans. That is why I need to find and separate out files with no Exif DateTimeOriginal.

My mistake, during testing I modified date taken within DOpus and it was reflected in exiftools when running...

exiftool -p "$filename has date $DateTimeOriginal" -q -f image.jpg

Turns out this is not the case when date taken is empty within DOpus, only when changing a date that's already there. Ignore the script I posted.

Where can I find this? Thanks.

This will most likely be caused because you either don't have exiftool in your path, or dopus doesn't know where it is. So a button command would look like this:

cd "C:\path\to\exiftool"
@async:"C:\path\to\exiftoolexiftool.exe" @ {allfilepath|filem} 

Based on plenty of info detailed in this forum, I think the simple way is to just drag the command onto the toolbar, and a helpful dialog pops up to assist in creating the command for the button.

I'd highly recommend watching this video:

Yonder,
Thank you for trying to help.

ThePauler,
Thank you. I watched part of the video, and I'll watch more later.
ExifTool is in my path. DOpus definitely knows where ExifTool is because I have a few commands that use ExifTool, and they work.
I still need to figure out how to select photos with no Exif DateTimeOriginal. Preferably with a button so the results are not in a collection.

If you want to avoid collections, your only option is to turn on Flatview and sort by DateTimeOriginal.

Collections still allow you to recreate folder structures, though, there are several threads on the forum.

Searching for files with DateTimeOriginal before 1900-01-01 seems to be a good approach to finding files with this field empty (it was in my testing). If it's not reliable, you could define an extra test column like this:

exifColumns.push_back(GetColumnMap('EXIF', 'DateTimeOriginal', 'DTOcheck', 'DTOcheck', 'DTOcheck', 'empty', '', ''));

and search for DTOcheck equals "empty".

Try the new version of the add-in I just posted, you should see a nice improvement in performance and stability. If you still run into problems, have a look at the logs, which btw you can simply save:

image

Thank you. I have not been able to test your improvements, as I'm past that stage with my current project.
As I wrote previously...

Perhaps sorting by Exif DateTimeOriginal will better with the improvements you've made. I hope so!