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. Avec this, exiftool will recurse into all subdirectories.
-if: The PH7 option. 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"