Here's the deal, i'm an absolute beginner and i'd to do this. I'd asked chatgpt and it came up with this code. Somehow, it's not working. I'd check everything and it should be. I also want to make sure that this doesn't mess any of the meta data up.

exiftool '-Directory<Modified/${Model;s/[^a-zA-Z0-9]/_/g}' -r Photos
exiftool '-Directory=Modified/Miscellaneous' -r -if 'not $Model' Photos
  • \$\begingroup\$ 1) If you are on Windows, replace single quotes by double quotes. You can also try to use backslashes (`) instead of slashes ('/'). 2) It is probably also a <` and not a =in -Directory=Modified/Miscellaneous (difference between Move and Copy). \$\endgroup\$
    – xenoid
    Commented Jan 12 at 9:06
  • \$\begingroup\$ @xenoid, if i try running it with a <, it throws this error! Warning: No writable tags set from Photos/Screenshot 2024-01-12 at 4.38.17 PM.png Warning: Invalid tag name 'modified/miscellaneous'. Use '=' not '<' to assign a tag value - Photos/Screenshot 2024-01-12 at 4.38.17 PM.png 1 directories scanned 1 files failed condition 0 image files updated 1 image files unchanged \$\endgroup\$
    – yoloxolo
    Commented Jan 12 at 11:10
  • \$\begingroup\$ Since exiftool is a Perl program, file paths can use slashes and backslashes interchangeably. Internally, they will all be converted to slashes. Even the Windows "executable" is simply the Perl script zipped up with a minimal Perl interpreter that is extracted to the %TEMP% and run from there. See the Perl PAR::Packer module. \$\endgroup\$
    – StarGeek
    Commented Jan 12 at 16:30

1 Answer 1


You don't mention your OS and the type of quotes you use is dependent upon what OS/Shell you are using. You would use single quotes to surround options on Mac/Linux and double quotes in Windows CMD. I'm going to assume you're using Windows CMD.

Your first command should work as long as you use double quotes. The less than sign is needed because this is a tag copy operation, as the tag Model is being copied into the directory name

exiftool "-Directory<Modified/${Model;s/[^a-zA-Z0-9]/_/g}" -r Photos

The second command should also work with double quotes. Because there isn't a tag being copied, only a static string, it requires an equal sign. See Exiftool Common Mistake #5c.

exiftool "-Directory=Modified/Miscellaneous" -r -if "not $Model" Photos

These two command can be combined into a single command. As per Note #1 under the -TAG[+-^]=[VALUE] option, when there is more than one assignment to the same tag, here the Directory tag, the latter assignment takes precedence. In this case, if there is a Model tag in the file, then the file will be moved to a directory of Modified/Model. If Model doesn't exist, it will fall back to the previous assignment of Modified/Miscellaneous.

exiftool -r "-Directory=Modified/Miscellaneous" "-Directory<Modified/${Model;s/[^a-zA-Z0-9]/_/g}" Photos

Neither of these commands will edit any of the embedded metadata.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.