Find jpg fichiers sans Keywords/Subject in Iptc/Xmp and copy them

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Find jpg fichiers sans Keywords/Subject in Iptc/Xmp and copy them

Message par ForumBot »

J'ai 10s of thousands of JPG photos in multiple sub-dossiers under a single dossier and quite a few duse picture fichiers have no keywords dans leir metadata.

Je veux find a way to scan through all dossiers and copy or move all JPG fichiers that *ne pas have keywords* to a duplicated same dossier structure.

Comment puis-je do this?

I've got W10 and **Exiftool** and I'm familiar avec Batch scripting.

Regarding the example below notez que the keyword's presence is NOT indicated by the actual image name. Those names dans le example image are seulement to help illustrate which images do and ne pas have keywords dans leir metadata.
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Find jpg fichiers sans Keywords/Subject in Iptc/Xmp and copy them

Message par ForumBot »

This can be done avec a single exiftool command. Exiftool has powerful batch ability built in and il y a almost jamais a need to créez un script.

The one caveat is that you must first CD invers le répertoire that is the start du tree you want to preserve. In your example, vous pourriez first CD into `F:\testFindNoKeywords`

Vous pourriez ensuite run this command in Windows CMD (not PowerShell). If run on Mac/Linux, vous pourriez changez le double quotes into single quotes:

`exiftool -r -if "not $keywords and not $subject" "-Directory=F:\testFindNoKeywordsResult\%d" .`

Breakdown:

- `-r`: The [PH4 (PH5) option](https://ExifTool.org/exiftool_pod.html#r-.--recurse). Avec this, exiftool will recurse into all subdirectories.

- `-if`: The [PH7 option](https://exiftool.org/exiftool_pod.html#if-NUM-EXPR). Cela va take the next parameter, which needs to be a Perl code expression, and compare the data in each fichier to that expression.

- `-Directory`: This tells exiftool that this sera a move operation vers le répertoire listed. The `%d` variable is filled in avec the répertoire chemin vers le fichier being processed. The valeur sera based upsur le répertoire given sur le ligne de commande. Si le ligne de commande is given an absolute chemin, ensuite this will contadans le absolute chemin vers le fichier. Ceci est why vous devez CD invers le répertoire en haut du tree you want to copy. The result sera the relative chemin vers le répertoire, which can be appended vers le nouveau répertoire location.

- `.`: The dot represents the current répertoire.

Ici's some example output. Files `1.jpg` and `2.jpg` each have a entry in `Keywords` or `Subject`. Fichier `3.jpg` ne have any keywords. The result is that fichier `3.jpg` is moved vers le nouveau répertoire while preserving the répertoire tree.

```
Y:\!temp\x\y>tree .\a /f
Folder PATH listing for volume DrivePool
Volume serial number is 3881-4F27
Y:\!TEMP\X\Y\A
│ 1.jpg

└───b
│ 2.jpg

└───c
3.jpg


Y:\!temp\x\y>exiftool -G1 -a -s -Keywords -Subject -r .\a
======== ./a/1.jpg
[XMP-dc] Subject : 1
======== ./a/b/2.jpg
[IPTC] Keywords : 2
======== ./a/b/c/3.jpg
3 directories scanned
3 image files read

Y:\!temp\x\y>exiftool -r -if "not $keywords and not $subject" "-Directory=Y:\!temp\x\y\NoKeywordsFound\%d" .\a
3 directories scanned
1 directories created
2 files failed condition
1 image files updated
0 image files read

Y:\!temp\x\y>tree /f Y:\!temp\x\y\NoKeywordsFound
Folder PATH listing for volume DrivePool
Volume serial number is 3881-4F27
Y:\!TEMP\X\Y\NOKEYWORDSFOUND
└───a
└───b
└───c
3.jpg

```

C'est important to notez que you do **not** want to use exiftool in a loop, calling it once per fichier. Exiftool's biggest performances hit is the startup time and looping it over 10,000+ fichiers will significantly increase the prcoessing time. See [Exiftool Common Mistake #3, "Over-scripting"](https://exiftool.org/mistakes.html#M3)
Répondre

Revenir à « Windows 11 »