ExifTool Forum

ExifTool => Newbies => Topic started by: abebakker on July 29, 2012, 02:59:11 PM

Title: copy pictures based on "Keywords" tag
Post by: abebakker on July 29, 2012, 02:59:11 PM
I have a large set of pictures wich are all tagged with keywords. On my IPAD i don't want all the pictures, only the most beautiful ones. So I gave the most beautiful pictures the keyword "IPAD" (beside all the other keywords).
Now I would like to "select" all the pictures with the keyword IPAD and copy (not move) them to the directory I sync with my IPAD (d:\|IPAD). Of course I want to preserve all the exif information.
Is this possible with the exiftool? I cant find it in the forum, faq or guide.
Thanks in advance.

Title: Re: copy pictures based on "Keywords" tag
Post by: Phil Harvey on July 29, 2012, 08:55:07 PM
This command may do what you want:

exiftool -if '$keywords =~ /IPAD/' -directory=d:/IPAD -o dummy SRCDIR

where SRCDIR is the directory containing the images.  Use double quotes instead of single if you are in Windows.

The -o dummy is a tricky way to get the file to be copied instead of moved.

- Phil
Title: Re: copy pictures based on "Keywords" tag
Post by: abebakker on July 30, 2012, 07:37:51 AM
Thanks for the quick response.
It is almost working.
Except:
1. It only scans the source directory not the subdirectory's.
2. It only copies the first picture which satisfies the conditions and renames it to dummy without extensions (the other pictures which satisfies the conditions can't be copied because dummy already exist)

I've managed to bypass point 2, by adding %f (original filename) and %e (original Extension) to dummy.

exiftool -if "$keywords =~ /IPAD/" -directory=D:/IPAD -o dummy%f.%e D:\Foto

Is there a way to also scan subdirectories?
Title: Re: copy pictures based on "Keywords" tag
Post by: Phil Harvey on July 30, 2012, 08:43:00 AM
Quote from: abebakker on July 30, 2012, 07:37:51 AM
1. It only scans the source directory not the subdirectory's.

Add -r.

Quote2. It only copies the first picture which satisfies the conditions and renames it to dummy without extensions (the other pictures which satisfies the conditions can't be copied because dummy already exist)

Oops.  Right.  That should be -o dummy/ (to make this a dummy directory name).  I should read my own documentation (see example 5) (https://exiftool.org/filename.html).

- Phil
Title: Re: copy pictures based on "Keywords" tag
Post by: abebakker on July 30, 2012, 09:27:44 AM
Thanks.
Works perfect.
Title: Re: copy pictures based on "Keywords" tag
Post by: d.l.g. on December 07, 2012, 02:24:56 PM
I would like to synchronize my photos between SOURCE and DEST directories with this conditions:
1- filtering photos by keyword:         -if "$keywords =~ /KEYWORD/"
2- scan also subdirectories:              -r
3- copy the structure of folders/subfolders:   ?
4- have a MIRROR in Dest folder (unidirectional sync: overwrite only if modified, delete if not present in source):   ?

I think I could do it using ExifTool for first three points from SOURCE to a TEMP folder; and FreeFileSync (or other...) from TEMP to DEST folder.
But this is not good for thousand of photos and for an updated Dest folder because I have to regenerate a new TEMP folder every time.
There is a solution for this? There is a complete software/tool that could do that?
Thanks.
Title: Re: copy pictures based on "Keywords" tag
Post by: Phil Harvey on December 07, 2012, 02:44:10 PM
If you know some Perl you could write a script to do this without too much trouble (using Image::ExifTool to extract your metadata).

Another possibility is to use ExifTool to simply generate a list of filenames for you, then pass this to some sort of sync tool.

I don't know of an off-the-shelf all-in-one solution for this.

- Phil
Title: Re: copy pictures based on "Keywords" tag
Post by: d.l.g. on December 09, 2012, 10:49:26 AM
Good idea!
I create a list and then I have to adapt the content out.csv to the required format in sync tool.

   exiftool -if "$keywords =~ /KEYWORD/" SRCDIR -sourcefile -csv > out.csv

But ExifTool takes 30 minutes to scan about 15,000 photos and create a list of those filtered in out.csv (1 CPU Pentium M 1.5 GHz).
Is there a way to speed up the scanning? I've checked the controls (-fast -fast2) but are not suitable.
Title: Re: copy pictures based on "Keywords" tag
Post by: Phil Harvey on December 09, 2012, 03:11:50 PM
That's 8 seconds per file.  Wow, that's slow.  On my system, I get about 50 files per second, which is 400x the speed you are seeing.  (my system is a 2.7 GHz Intel Core i5)

One thing that may cause things to run slowly is if exiftool is using too much memory.  The -csv option is very memory intensive when run on a large number of files.  Instead, try using -p "$directory/$filename" (or single quotes for Mac/Linux)

Why do you say -fast2 isn't suitable?  It is rare to fine IPTC in the file trailer.  On my system the speed goes from about 50 files/second to about 65 files/second with -fast2 (on a mixture of files, but mostly JPEG images from cameras).

- Phil

Title: Re: copy pictures based on "Keywords" tag
Post by: d.l.g. on December 11, 2012, 05:04:14 PM
...would be 8 file per second!

I've made more accurate tests:
1) -csv             takes  11,5 files per second
2) -p                takes  11,5 files per second
3) -csv -fast2   takes  16,4 files per second
4) -p    -fast2   takes  16,2 files per second

- No difference between  -csv and -p
- Improvement of 42% with -fast2  (perhaps the last time I had some background process)

Considering (1CPU --> 2CPU: 2x) and (1,5GHz --> 3GHz: 2x) you have 4x speed (50/65 files per second) compared to my scanning speed.
It 's in line with the technology, my PC has 9 years...
Title: Re: copy pictures based on "Keywords" tag
Post by: Phil Harvey on December 11, 2012, 08:21:45 PM
Looking back I see I was wrong with the 8 seconds per file number -- it was actually 8 files/second, which isn't as bad as I was thinking.

As you say, given the system difference this isn't too far off the mark.  So maybe there isn't too much room for this to improve.  But the 2x CPU's doesn't help me at all since ExifTool is a single-thread process.

However, I still wouldn't recommend using -csv on such a large number of files.  I don't know how many files you used in your speed tests, but if ExifTool uses enough memory to require swapping to disk then things will slow down significantly.

    -csv
        [...]
        Note that this option is fundamentally different than all other output format options because
        it requires information from all input files to be buffered in memory before the output is written.
        This may result in excessive memory usage when processing a very large number of files with a
        single command.

- Phil
Title: Re: copy pictures based on "Keywords" tag
Post by: d.l.g. on December 17, 2012, 09:42:51 AM
(I've used about 11.000 files)
Ok, thanks for all.