ExifTool Forum

ExifTool => Newbies => Topic started by: Mathersss on September 24, 2018, 05:05:45 AM

Title: How to use an image's name to add tags to it ?
Post by: Mathersss on September 24, 2018, 05:05:45 AM
So I'm a complete novice, all what I want to do is use an image file's name as its tags, I have a lot of images and it'd take an insane amount of time to do this manually and I've been trying to find a way to do this for a while now (7 months).

So most my image file names are formatted with spaces and underscores

I use spaces as tag separators so my images are like:

Samuel Shaunta_Mathers zoo weekend windy.jpg

ps: other files can be long but the format is the same

I want the image tags to be
Samuel;Shaunta_Mathers;zoo;weekend;windy

so how can I edit all my images like that ? Is it possible ?

to say it more clearly I want any words connected by underscores to be considered as one tag and use any space as tag separators.

I'm using Windows 8.1


Thank you in advance


Title: Re: How to use an image's name to add tags to it ?
Post by: Phil Harvey on September 24, 2018, 07:33:36 AM
Your first challenge will be to figure out how to install/run ExifTool from the command line.  But once you do this, the command would be:

exiftool -P -r "-subject<${filename;s/\.jpg$//i}" -sep " " -ext jpg DIR

This will recursively process all JPG files in directory DIR, adding all words in the file name to the XMP Subject.  After doing this you will have an "_original" backup file for each file.  You can avoid creating these by adding -overwrite_original to your command, or remove them later with this command:

exiftool -delete_original -r -ext jpg DIR

But you should be sure that the command does what you want before removing the originals.

- Phil
Title: Re: How to use an image's name to add tags to it ?
Post by: Mathersss on September 24, 2018, 09:10:08 AM
Thank you sir, It's working like a charm, thank you  ;D I can't express how grateful I am, I've been trying to do something like this for months, you're amazing