Main Menu

Default keywords separator?

Started by thany, January 07, 2022, 03:22:30 PM

Previous topic - Next topic

thany

Every single time I do something with keywords, and I want to add keywords from anywhere into, well, the Keywords tag, I end up doing something like this:

exiftool -P -progress -r -overwrite_original_in_place -csv+=files.csv .

Aaaaand, that's a big whoops :( Every SET of keywords is now added into the Keywords tag as a SINGLE keyword. That's no good :( If this wasn't bloody hard to undo, it would only be a bit annoying, but removing arbitrary keywords from arbitrary existing keywords is a really hard thing to do. There's no "-=" operator on the -csv argument, is there... Right?

And yes, finally, after I've undone my mistake:

exiftool -P -progress -r -overwrite_original_in_place -sep "," -csv+=files.csv .

Exiftool can be quite unforgiving at times :-\

So, I've been searching high and low, and I have yet to find an answer to the (to me pretty simple) question: what's the default? What does exiftool assume the separator is, when none is given?

StarGeek

Quote from: thany on January 07, 2022, 03:22:30 PM
Every single time I do something with keywords, and I want to add keywords from anywhere into, well, the Keywords tag, I end up doing something like this:

exiftool -P -progress -r -overwrite_original_in_place -csv+=files.csv .

Aaaaand, that's a big whoops :( Every SET of keywords is now added into the Keywords tag as a SINGLE keyword.

From the docs on the -csv option
     List-type tags are stored as simple strings in a CSV file, but the -sep option may be used to split them back into separate items when importing

If you add the -sep option
-sep ", "
The keywords will be split into the separate keywords.

QuoteIf this wasn't bloody hard to undo, it would only be a bit annoying,

To turn the single long keyword into separate keywords, you would use the -sep option with the -TagsFromFile option
exiftool -sep ", " -TagsFromFile @ -Subject -Keywords /path/to/files/

Quotebut removing arbitrary keywords from arbitrary existing keywords is a really hard thing to do. There's no "-=" operator on the -csv argument, is there.

No, there isn't.

QuoteSo, I've been searching high and low, and I have yet to find an answer to the (to me pretty simple) question: what's the default? What does exiftool assume the separator is, when none is given?

To separate keywords in a csv file?  There is none.  You have to add the -sep option as stated above.

FAQ #17 and FAQ #26 give more info on List type tags and importing from csv file.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

thany

Thanks for the tips!

But seriously, I think there should be a default. Otherwise the -sep argument is practically always required, unless you're trying to do something really weird - but then I'd suggest requiring -sep "" to remove the default.

Think of it this way: when would you ever want to treat a list of keywords, being poured into a "list" tag, not as a list, but as a concatenated string, making it a list of 1? Is there ever a situation where that's useful? And wouldn't that be the exception?

I think a comma or semicolon would be sensible default.

/edit
In the same way, reading csv also has a sensible default for column separation: the comma. That too, doesn't require a setting, where by default it would read an entire row as a single column :)

Phil Harvey

I suggest you use JSON instead of CSV if you want to properly restore lists of items.  The deficiency is due to the fact the CSV doesn't support items that are lists.

I don't think it is a good idea to make the -sep option default when importing CSV because:

1. It would be inconsistent with the behaviour for all other options.

2. It would be incompatible with list items which contained the chosen separator.  It is better to let the user specify the separator that works for them.

3. There is no clear choice.  ExifTool defaults to comma-space when writing, but I think semicolons are more common for separating items within a CSV entry.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: Phil Harvey on January 07, 2022, 09:34:41 PM2. It would be incompatible with list items which contained the chosen separator.  It is better to let the user specify the separator that works for them.

My favorite example of this
"Smith, John"
"Doe, Jane"
"Williams, Mark A., III"
You would now have 7 separate keywords if you assume a comma.  This was a PITA when using the old Google Picasa software because it automatically split any keyword with a comma into two separate keywords with no way that I could find to disable it.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).