Using < to re-map CSV properties

Started by Martin Z, May 22, 2023, 05:19:35 PM

Previous topic - Next topic

Martin Z

Hi Phil, StarGeek, everyone...

- I use code like the snippet below to set metadata to files from a CSV...
EXIFTool -csv=Metadata.csv -e -d "%%d/%%m/%%Y %%H:%%M:%%S" -sep ";"
         "-AllDates<CreateDate" "-FileModifyDate<CreateDate" "-FileCreateDate<CreateDate"
         -overwrite_original .

Focussing on the middle line specifically, the intention is to set all metadata dates, and the Windows 'created' and 'modified' date to value stored in the CreateDate COLUMN, in the CSV. However, as part of StarGeek's recent reply to my post: Any gold standard EXIFtool scripts? (thanks btw), made me think actually this syntax didn't do that...

Quote from: StarGeek on May 17, 2023, 02:38:49 PMAny TAG<TAG operation implies -TagsFromFile @ unless an explicit -TagsFromFile

If it doesn't please could you let me know how what syntax I should use instead to essentially copy values from 1 column in the CSV to multiple tags in the target file

StarGeek

Note #1 from the -TAG[+-^]=[VALUE] option applies
     Many tag values may be assigned in a single command. If two assignments affect the same tag, the latter takes precedence

C:\>type temp.csv
SourceFile,FileCreateDate,FileModifyDate,Description
y:/!temp/Test4.jpg,2023:04:16 12:00:00-07:00,2022:05:17 12:00:00-07:00,New Description

C:\>exiftool -G1 -a -s -FileCreateDate -FileModifyDate -Description y:\!temp\Test4.jpg
[System]        FileCreateDate                  : 2021:01:01 12:00:00-08:00
[System]        FileModifyDate                  : 2020:12:12 12:00:00-08:00

C:\>exiftool -P -overwrite_original -csv=temp.csv "-FileCreateDate<FileModifyDate" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -FileCreateDate -FileModifyDate -Description y:\!temp\Test4.jpg
[System]        FileCreateDate                  : 2020:12:12 12:00:00-08:00
[System]        FileModifyDate                  : 2022:05:17 12:00:00-07:00
[XMP-dc]        Description                     : New Description

First, the values from the CSV will be applied.  But then FileCreateDate is now being set from the original FileModifyDate, as you can't write a tag and then copy that new value into another tag.  The result is that FileModifyDate and Description have values set from the CSV, but FileCreateDate will have the original value of the FileModifyDate.

After resetting the values
C:\>exiftool -G1 -a -s -FileCreateDate -FileModifyDate -Description y:\!temp\Test4.jpg
[System]        FileCreateDate                  : 2021:01:01 12:00:00-08:00
[System]        FileModifyDate                  : 2020:12:12 12:00:00-08:00

C:\>exiftool -P -overwrite_original "-FileCreateDate<FileModifyDate" -csv=temp.csv y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -FileCreateDate -FileModifyDate -Description y:\!temp\Test4.jpg
[System]        FileCreateDate                  : 2023:04:16 12:00:00-07:00
[System]        FileModifyDate                  : 2022:05:17 12:00:00-07:00
[XMP-dc]        Description                     : New Description

The tag copy has no effect, as the value from the CSV file is the latter assignment for FileCreateDate
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Martin Z

Hi @StarGeek,

["Quick" aside] First of all, thanks for explanation and including traced-through examples... Also, I remember you saying in one of your replies to my any "gold standard" scripts, that you had basically ran out of time and would need to pick up later and I always meant to follow-up and just say...
  • It's totally fine, I appreciate any time you are able to spend to try and help me and other out!
  • Even from my own very limited time on the forum, I know how long this stuff takes... I am a bit of a perfectionist
  • I generally try† and write comprehensive questions/answers (incl. code snippets, mock files, etc) as this is my way of showing respect -- as in making the effort to try and explain clearly, so that you guys can go straight to the fix/answer and don't have to spend your time figuring out what I mean, because I couldn't be bothered to write more than a sentence in the first place. [that's my intent/approach anyway, some time we will have to discuss how well I actually succeeded at 'minimising' the time requirements on your side! 🙈]...
  • A few nights ago, I spent ~1 hour composing a follow-up but ultimately it got too late and I had to park it and go to bed...
  • But anyway, MY POINT IS that I know first hand how long it can take when you're trying to check something out, preparing multiple tests/scenarios, creating psuedo console outputs and file details, etc and trying to post it all in a way that looks decent.... I can't say how much the average forum member realises how long this all takes, but as I do, once again just want to say thanks to you, Phil and others for putting all this time in!

Anyway, back to the topic at hand... In the week or so since writing my draft (un-posted) reply, my understanding has moved on slightly and so I think I have identified the 'core issue' (or arguably user error) that was causing my confusion.



Core issue/confusion (potentially)

  • I think this essentially comes down to ' < ' not quite working like I thought it did [your last reply reinforced this, so hopefully am not too far off this out now]
  • In summary, I have been treating ' < ' as a "column-remapper" (especially, bearing in mind that over half of the time I am using EXIFtool to read/write properties from a CSV...
  • Using your reply to demonstrate what I mean...

Quote from: StarGeek on May 23, 2023, 12:34:14 PMexiftool -P -overwrite_original -csv=temp.csv "-FileCreateDate<FileModifyDate" y:\!temp\Test4.jpgFirst, the values from the CSV will be applied.  But then FileCreateDate is now being set from the original FileModifyDate

⬆️ Your explanation summaries this quite well (and where my likely mis-understanding has been), as interestingly although what you described makes sense, this is not actually (at all) what I was trying to get EXIFtool to do in this instance...
  • I assumed EXIFtool was using the CSV as the ONLY source of info for writing the tags...
  • In this case, the CSV contained a fully-populated column of "CreateDate" and so would write this to the CreateDate tag for each file
  • However, I was also using the "CreateDate" column as my 'master date' and wanted EXIFtool to use this value when setting the FileCreateDate and FileModifyDate
  • A nuance in my assumption/intention here, is that I essentially wanted EXIFtool to:
    🚫 Ignore the file's current 'created' or 'modified' properties
    🚫 Ignore the "FileCreateDate" and "FileModifyDate" columns in the CSV
    ✏️ Take the value in the CSV column "CreateDate" and write this too all "all dates" and the file properties
... Interestingly, I hadn't realised (or wanted) EXIF to try and set these columns twice

So, hoping the above makes sense (and bringing it all back to the post title)... Is there a way I can tweak my script/syntax and essentially give create a [CSV-column]-to-[File-property/tag] mapping that EXIFtool can then apply?



My Testing (albeit potentially superseded)

Hopefully the above makes sense. If further explanation would help though, this is where I will try and salvage and re-purpose the draft post I mentioned near the beginning...

Context
I have been using EXIFtool for a few months, one of my most common tasks involves having a bunch of non-metadata files, taking a CSV with various tags/columns and using EXIFtool to write the data in the CSV into the corresponding tags for each file. This process largely works fine, however there were some minor issues when it came to setting the various date properties...

Scenario
- Imagine a photo taken Christmas day 2000 (25/12/2000)
- It was uploaded to twitter and I download it to my machine today (18/05/2023)
- We'll consider the (Windows) Date Taken property is either correct (25/12/2000) or not populated
- The FileCreate and FileModify datestamps are both set by Windows to today (18/05/2023) because that's when the file first appeared on my machine
- For my purposes, while the  FileCreate and FileModify timestamps may be technically correct, they are kind of a misnomer as if I search for recent photos I don't really want this one showing up
- I have produced the below CSV file to help me manually set/correct the tags in the file.


Metadata.csv
-----------------------------------------------------------------------------------------------------
| SourceFile         | CreateDate       | FileModifyDate   | XPKeywords                 | Title     |
-----------------------------------------------------------------------------------------------------
| XmasDay-Photo1.jpg | 25/12/2000 09:00 | 25/12/2000 09:00 | Christmas; Family; Twitter | Xmas 2000 |
| XmasDay-Photo2.jpg | 25/12/2000 17:00 | 25/12/2000 17:00 | Christmas; Family; Twitter | Xmas 2000 |
-----------------------------------------------------------------------------------------------------

> DIR *.jpg
XmasDay-Photo1.jpg:  Has the correct value already for DateTaken, but created and modified dates need aligning
XmasDay-Photo2.jpg:  Has no DateTaken info and the created and modified dates need aligning too

VERSION 1: CreateDate
> EXIFTool -csv="Metadata.csv"- -e -d "%d/%m/%Y %H:%M:%S" -sep ";" -overwrite_original
  "-AllDates<CreateDate" "-FileModifyDate<CreateDate" "-FileCreateDate<CreateDate" .
Result: ✅ (partial)
Notes:  In testing, this generally seemed to work fine, as in the 'date taken', created and modified dates would be set to 25/12/2000 (as I wanted), however in the case of File2.jpg (where this tag doesn't exist yet), it would set the correct date but also throw a "Warning: No writable tags set from..." message (which always confused me, but I think now makes sense given your explanation).

I saw on the forum people had also encountered this warning and as a general rule, the advice was to switch your script to reference FileModifyDate instead (as this tag would always exist, and so would not cause the warning message), however...

VERSION 2: FileModifyDate
> EXIFTool -csv="Metadata.csv"- -e -d "%d/%m/%Y %H:%M:%S" -sep ";" -overwrite_original
  "-AllDates<FileModifyDate" "-FileModifyDate<FileModifyDate" "-FileCreateDate<FileModifyDate" .
Result: ❌
Notes:  I switched/duplicated the "master date" column in the CSV (now ensuring that each row had a correct value for the FileModifyDate column instead. However EXIFtool ignored the corrected value in the CSV column "FileModifyDate" and instead copied the current (but wrong!) FileModifyDate value to the other properties.
Extra:  At the time this threw me, but like I say now knowing a bit more about < this makes sense now

TESTING INCOMPLETE
  • I had planned to test some additional scenarios, around using a "master date" column idea, compared to just duplicating the column 5-6 times with different names... however I ran out of time, and think this may not be needed now anyway.
  • I don't plan to add to/complete this section specifically but more than happy to clarify or expand on anything, so if you want me to do that just let me know.

Again, the testing notes are likely surplus at this point, so I don't want to spend much more time on this section. The main point outstanding is understanding if/how I can use ' < ' (or some other syntax) to map CSV columns to different tags.

StarGeek

Quote from: Martin Z on May 25, 2023, 04:15:41 PMIs there a way I can tweak my script/syntax and essentially give create a [CSV-column]-to-[File-property/tag] mapping that EXIFtool can then apply?[/b]

No.  Writing from a CSV file is just like writing each item independently on the command line so latter assignments take precedent as per Note #1 above.  A CSV file can be thought of as an individual command using the assignments in the CSV file for each file processed, just like each line in the CSV file was an independent command, without the startup overhead.  Basically as if each line was processed with the -execute option
line 1 do assignments -execute
line 2 do assignments -execute, etc

That's a bit of an over simplification, I think.

Quote- Imagine a photo taken Christmas day 2000 (25/12/2000)

Relevant xkcd - ISO 8601  ;)


Quote- It was uploaded to twitter and I download it to my machine today (18/05/2023)
- We'll consider the (Windows) Date Taken property is either correct (25/12/2000) or not populated

I don't do twitter, but I would surprised if it showed any value.  Most social media (FB/IG for certain) strip away most, if not all, metadata.

QuoteThe main point outstanding is understanding if/how I can use ' < ' (or some other syntax) to map CSV columns to different tags.

It will have to be a two step procedure.  Write data using CSV, then a second command to copy from the embedded time stamps to the file system ones or something like that.

Or script up something to edit the csv files.  As I mentioned here, the command line programs,  CSVKit and xsv can be used to edit CSV files.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

StarGeek

Quote from: Martin Z on May 25, 2023, 04:15:41 PMAlso, I remember you saying in one of your replies to my any "gold standard" scripts, that you had basically ran out of time and would need to pick up later and I always meant to follow-up and just say...

I did eventually get back to it, though I don't think there was much else to say.  But after answering that I realized I had spent close to 9 hours over the past 3 days doing nothing but answering exiftool questions, here and on reddit and stackexchange, and needed to step away.

Similar situation today.  Spent a couple hours typing stuff up, trying to catch up to the back log.  So I'm logging off for a bit.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Good for you StarGeek.  Take care of yourself.  :)

- 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 ($).

Martin Z

EDIT: I wanted to write some 'quick quips' to 1-2 things in your last reply but as is often my problem I got far too detailed and it came out far too long. Before you read the below I just want to echo Phil's comment and re-iterate...
• Thanks on behalf of (a) myself as know you have spent good chunks of time helping me personally and (b) the wider community as also know how much of your time this eats up!
• Please do take breaks / time-off and don't get too stressed by feeling obligated to spend all your free time helping (ironically I am insanely bad at following this advice myself and have had burnouts in the past), but as others have said to me: "there will always be more to do and nothing is so important that the world will end if it's not done today" ❤️


PRIORITY: ⬇️LOW

Quote from: StarGeek on June 04, 2023, 06:58:43 PMI don't do twitter
Lol, well and quite right, and I don't use it either myself... however friends and family have an annoying habit of putting family photos and things on there, and after countless failed requests for media (usually the best result being getting only a handful of images, sent through WhatsApp, low-mid quality, compressed, with metadata removed) scraping them from sites like twitter.com and instagram.com ultimately became the lesser of two evils!

Quote from: StarGeek on June 04, 2023, 06:58:43 PMI would surprised if it showed any value. Most social media (FB/IG for certain) strip away most, if not all, metadata.
Oh @StarGeek, no, no, no if only you knew!!
 └  OK Yes, you are right(ish) 🙂 -- in terms of what you can get from the webpage/browser, the info is very limited and you are also right that most sites strip most if not all metadata out of the image/video file(s)
 └  HOWEVER -- There is a hidden trove of extractable metadata you can access if you are geeky / determined / obsessive -enough (and luckily I meet all those criteria! 😁🙈)

EXAMPLE
• Test post: I searched for "london" and this is the first public tweet I found, so ignore the actual context/content
• URL: https://twitter.com/LondonEconomic/status/1669724117216509952
• Metadata available on the page: minimal
• Metadata available with tools like gallery-DL: 39 data points...
{
    "width": 1080,
    "height": 1080,
    "bitrate": 1280000,
    "duration": 133.5,
    "description": null,
    "tweet_id": 1669724117216509952,
    "retweet_id": 0,
    "quote_id": 0,
    "reply_id": 0,
    "date": "2023-06-16 15:10:26",
    "author": {
        "id": 1593295976,
        "name": "LondonEconomic",
        "nick": "The London Economic",
        "location": "London",
        "date": "2013-07-14 12:36:49",
        "verified": false,
        "profile_banner": "https://pbs.twimg.com/profile_banners/1593295976/1672862039",
        "profile_image": "https://pbs.twimg.com/profile_images/1412068975517876225/6L995dKq.jpg",
        "favourites_count": 10185,
        "followers_count": 65586,
        "friends_count": 50512,
        "listed_count": 708,
        "media_count": 7732,
        "statuses_count": 95781,
        "description": "A progressive voice for a metropolitan community. \n\nSign up to Elevenses, our free newsletter: http://thelondoneconomic.com/newsletter ��",
        "url": "http://www.thelondoneconomic.com"
    },
    "lang": "en",
    "favorite_count": 6,
    "quote_count": 0,
    "reply_count": 0,
    "retweet_count": 7,
    "content": "\"There are natural trading and commercial relations between Britain and the continent. These have very obviously been harmed.\"\n\nBrexit has turned the UK into a \"vassal of the United States\", Noam Chomsky explains.",
    "count": 1,
    "category": "twitter",
    "subcategory": "timeline",
    "num": 1,
    "filename": "WQ1lJGsHc3TbmdwH",
    "extension": "mp4"
}

Caveat: Admittedly some data points are less useful than others and many are irrelevant or can be calculated (e.g. width)
Reminder: Again, this is random just a test file. Generally speaking it's possible to get a fair amount of 'useful' metadata like the date taken, author, title, tags/keywords, tagged users/people, etc
Disclaimer: I am not advocating for gallery-DL specifically, rather just providing it as an example as it one of the tools I use for gathering metadata. Feel free to look into it if you're interested or completely ignore it if not, completely up to you (and/or anyone else reading this later)



Quote from: StarGeek on June 04, 2023, 06:58:43 PMRelevant xkcd - ISO 8601  ;)

OK, this one cut deep @StarGeek!  :'(

OK, I know... at least hope you're mostly joking on this one as this one is a little close to my heart...

1️⃣ Hey, at least I'm not American! (sorry Phil, I know you're American-adjacent) -- But I mean, seriously how they ever thought 'MMM DD YYYY' was a sensible date format is something I don't think I will ever understand (but what makes it a killer is that so often it is the default, or in some cases the ONLY date format available in various sites/apps)

2️⃣ I do often use YYYY-MM-DD at home / for my own files, but as this feels a little 'too geeky' for the average person I tend to default to DD/MM/YYYY on the internet -- don't get me wrong, I know it is far from perfect, but at least it's sequential!

3️⃣ I have had SO many discussions professionally where I have tried to educate (and in some cases even argue with people) why not to use 6-digit date formats...
QuoteBecause Tracy, if you put '21-06-20' I don't know if you mean the 21st June 2020, or 20th June 2021! So, for the 18th time please use a 4-DIGIT YEAR!!
OK, I am definitely getting triggered / painful flashbacks as I write this! 😁

4️⃣ The other endlessly reoccurring argument/battle that I get professionally is working with teams/people who prefix their filenames with dates, e.g. "2020-10-11 - HR Policy, Annual Leave.docx"
QuoteOK Tracy, thank you for using an 8-digit date, but the reason I said to put it at the end of the file is so that you can still sort and search the files alphabetically... Given I started a month ago, how would I know to look for the 'annual leave policy' under "2020"!?... We can store the 'last updated' date in a separate column and do a sort on that column when you want to get the files in date order, please stop putting it at the beginning of the file because you're too lazy to change the sort column in explorer! 🤬

Anyway, the point I was trying to make was after considering myself somewhat as an arbiter of the importance of good (meta)data and spending a good chunk of my time trying to fix the bad habits of others, your XKCD wounded me deeply my friend!  :'(  ;D



OK, as I put at the beginning I admittedly got a little carried away on this one; I will try and do a more relevant (and succinct!) follow-up shortly.

Martin Z

#7
Quote from: StarGeek on June 04, 2023, 06:58:43 PMNo. Writing from a CSV file is just like writing each item independently on the command line so latter assignments take precedent
[...] It will have to be a two step procedure. Write data using CSV, then a second command to copy from the embedded time stamps to the file system ones or something like that. Or script up something to edit the csv files.

Thanks for your reply. I don't think this will change what you said, but I wasn't 100% sure if explained what I wanted to do, so at the risk of repeating myself I thought I would clarify (just in case there is a solution I am missing)...

In essence, this is about trying to do things in the CSV...
1️⃣ Convert 'non-standard' tag columns into 'EXIFtool-readable' columns
2️⃣ More crucially - re-use a single column in the CSV and apply the value stored to multiple tags

[PS: Your points about later assignments taking precedent and each line/row being processed as if with an identical execute command are both fine, no worries]

Example
(Merits of this exact action aside) say I have 100x files and for each file I want to standardise (set the same value) for the various dates stored in metadata...
• NOTE 1: This means for 1 file, setting multiple tags to the value stored the given CSV row (no exceptions/ adhoc processing)
• NOTE 2: The dates between rows would vary (different dates for different files)

Current solution
AFAIK, the only way to do this currently would be to have multiple columns in the CSV with the same data; EXIFtool will then populate these tags as it maps the data from the CSV on a strict 1-to-1 basis...
Set_Dates.csv
=============
| SourceFile | CreateDate          | DateTimeOriginal    | FileModifyDate      | FileCreateDate      |
| ---------- | ------------------- | ------------------- | ------------------- | ------------------- |
| File1.jpg  | 2022:10:01:23:59:59 | 2022:10:01:23:59:59 | 2022:10:01:23:59:59 | 2022:10:01:23:59:59 |
| File2.jpg  | 2021:09:12:22:00:00 | 2021:09:12:22:00:00 | 2021:09:12:22:00:00 | 2021:09:12:22:00:00 |
| File3.jpg  | 2023:02:23:12:15:00 | 2023:02:23:12:15:00 | 2023:02:23:12:15:00 | 2023:02:23:12:15:00 |
| File4.jpg  | etc...              | etc...              | etc...              | etc...              |

> EXIFtool -csv=Set_Dates.csv .
[EDIT: Also just to add that the above gets quite bad/messy for things like .mp4's as a single video file can have around 10 timestamps! 🙈]

While this is not the end of the world and certainly can be done, it just didn't seem great/optimal and hence why I thought I would ask if there was a better way of doing this...

Proposed/queried solution
What I was trying to understand if is there is someway I can do something like this instead, where I can have a single date column and tell EXIFtool to re-use it for multiple tags...
Set_Dates.csv
=============
| SourceFile | MasterDate          |
| ---------- | ------------------- |
| File1.jpg  | 2022:10:01:23:59:59 |
| File2.jpg  | 2021:09:12:22:00:00 |
| File3.jpg  | 2023:02:23:12:15:00 |
| File4.jpg  | etc...              |

> EXIFtool -csv=Set_Dates.csv "-CreateDate<MasterDate" "-DateTimeOriginal<MasterDate" "-FileModifyDate<MasterDate" "-FileCreateDate<MasterDate" .



If that does clarify better (and change your answer) then great!
IF that is what you understood initially (and so the answer is the same) then no worries, thanks anyway for your time on this!

StarGeek

Quote from: Martin Z on June 16, 2023, 06:41:51 PMProposed/queried solution
What I was trying to understand if is there is someway I can do something like this instead, where I can have a single date column and tell EXIFtool to re-use it for multiple tags...

Shortcut tags are your friend.  For example, AllDates as a column header will write CreateDate, DateTimeOriginal, and ModifyDate, covering two of your columns, though it does include one that you may or may not want to write.

Using your example CSV, you would add this to your .exiftool_config file.
%Image::ExifTool::UserDefined::Shortcuts = (
    MasterDate => ['FileCreateDate','FileModifyDate','CreateDate','DateTimeOriginal'],
);
#------------------------------------------------------------------------------
1;  #end

Examples from my config file

Because I'm lazy
FCD => ['FileCreateDate'],
FMD => ['FileModifyDate'],
CapAb => 'Caption-Abstract',
HS => 'HierarchicalSubject',
IDesc => 'ImageDescription',
DTO => 'DateTimeOriginal',

Writing GPS tags, both reference directions and the coordinates in EXIF and XMP at once.  Also writing the time stamps at once.
MyLong => ['GPS:GPSLongitude', 'GPS:GPSLongitudeRef', 'XMP:GPSLongitude'],
MyLat => ['GPS:GPSLatitude','GPS:GPSLatitudeRef','XMP:GPSLatitude'],
MyAlt => ['GPS:GPSAltitude', 'GPS:GPSAltitudeRef', 'XMP:GPSAltitude', 'XMP:GPSAltitudeRef'],
MyGPSTime => ['GPSDateTime','GPSTimeStamp','GPSDateStamp'],

Specific date/time tags
VidTime => ['Quicktime:CreateDate','Quicktime:ModifyDate','Quicktime:TrackCreateDate','Quicktime:TrackModifyDate','Quicktime:MediaCreateDate','Quicktime:MediaModifyDate'],
SysTime => ['FileCreateDate','FileModifyDate'],

And my version of all dates which writes EXIF, XMP, and the time zone tags
MyAllDates => ['EXIF:DateTimeOriginal','EXIF:CreateDate','EXIF:ModifyDate','XMP:DateTimeOriginal','XMP:CreateDate','XMP:ModifyDate','OffsetTimeDigitized','OffsetTimeOriginal','OffsetTime'],
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

StarGeek

Quote from: Martin Z on June 16, 2023, 05:14:34 PMOK, I know... at least hope you're mostly joking on this one as this one is a little close to my heart...

Yeah, I don't really care one way or the other.  I write the ISO version and annoy other people by doing so :D  I only get annoyed when coming across examples like yours.  Or like with CVS drugstore, where I get text message asking for my birth month and day, and give the example of "03/03"?!?  What the heck?  Which is which?  The did finally fix that, though.  Now they use something along the lines of "if your birthday was March 4, then write 03/04"
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Martin Z

#10
Quote from: StarGeek on June 17, 2023, 03:03:46 PMasking for my birth month and day, and give the example of "03/03"
Wow, I absolutely love that (because of like you say, just how spectacularly bad that is!)... geez, where do they find these people!? 🙈

Thankfully I don't have anything quite that bad, but what did annoy me was when I occasionally phoned my bank and one of the automated security prompts asked you (in the... slowest... voice... possible):
QuotePlease enter your date of birth...
For example, if you were born on the...
Twenty-eigth of february...
Nineteen ninety seven.

Please enter:
two, eight
zero two,
one ni--
-- "OK so you want 8-digit <beep, beep beep...> done!"... It's like, I don't need you to explain to me how dates work just tell me what format you want the data in.



[EDIT: Urgh, ISO standards - too much to say and go into here but in short: standards are good, great, essential. So I totally agree with the principle, just not always the specific implementation sometimes...]

I remember having a debate at work with the Information Management team..
  • I was developing a system with the International Dept. so needed a Country column
  • Bear in mind 95% of the data was in the UK, I asked if we could have "United Kingdom"
  • The Info Mgmt team said they'd already spec-ed this column based it on the ISO 3166 standard
  • I asked what this was for the UK, i.e. what value would we need to store/show for 95% of all docs...

They were really proud of their decision and implementation (and don't get me wrong, like I say standardisation is good), but as you can probably imagine this went down like a lead balloon with the users and the UI was just awful - The country column could have been 2-3 letters but ended up taking about half the screen! 🙈
 

Martin Z

Quote from: StarGeek on June 17, 2023, 02:57:59 PMSpecific date/time tags
VidTime => ['Quicktime:CreateDate','Quicktime:ModifyDate','Quicktime:TrackCreateDate','Quicktime:TrackModifyDate','Quicktime:MediaCreateDate','Quicktime:MediaModifyDate'],
SysTime    => ['FileCreateDate','FileModifyDate'],


Oh wow, awesome!... Yeah, this is exactly what I'm wanting to do! This is amazing, thank you!


Quote from: StarGeek on June 17, 2023, 02:57:59 PMShortcut tags are your friend. For example, AllDates as a column header will write [data to these tags:] CreateDate, DateTimeOriginal, ModifyDate
Ah cool!... Again, I've used AllDates a little but didn't realise I could use Shortcuts like this as CSV column headers, that's great!
I had looked at the example config page a few times but it seemed a bit advanced for my level so only really skimmed it TBH.
Your 'starter code' for me is great though as it really helped demystified the .exiftool_config for me quite a bit! 👍🏼

Going through it again now, I also see that...
  • Unknown tags may be extracted even if they aren't defined (but tags must be defined to be written)
     └ As if I'm understanding this right, I can use this to define the column but list it without any tag mapping(?) and that will let EXIFtool recognise a column but ignore it, yeah?
     └ Which am thinking might actually help me solve me "needing multiple CSV files" issue (because of having non-tag-name columns in the CSV for other scripts, but this creating a problem when EXIFtool then tries to process these columns)
  • It is possible to override an existing tag definition with a user-defined tag.
     └ Similarly, I understand the logic of why AllDates works the way it does, but part of me would have preferred if AllDates would update the FileCreateDate and FileModifyDate
     └ But again, understanding the .exiftool_config file better now, I could use this to override AllDates too right? #sogood!


Quote from: StarGeek on June 17, 2023, 02:57:59 PM%Image::ExifTool::UserDefined::Shortcuts = (
    MasterDate => ['FileCreateDate','FileModifyDate','CreateDate','DateTimeOriginal'],
);
#------------------------------------------------------------------------------
1;  #end

❓ Just one thing to check though, is the %Image part of %Image::ExifTool::UserDefined::Shortcuts significant?
As in, would I need to create a copy of these lines but with %Video::ExifTool::UserDefined::Shortcuts for when EXIFtool tool is processing video files?



Thanks again, this is awesome!


Phil Harvey

Quote from: Martin Z on June 18, 2023, 07:35:56 PM❓ Just one thing to check though, is the %Image part of %Image::ExifTool::UserDefined::Shortcuts significant?
As in, would I need to create a copy of these lines but with %Video::ExifTool::UserDefined::Shortcuts for when EXIFtool tool is processing video files?

No.  It is always Image::ExifTool

- 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 ($).

Martin Z

Quote from: Phil Harvey on June 19, 2023, 07:20:42 AMNo.  It is always Image::ExifTool

Awesome, thanks for confirming Phil 👍🏼

StarGeek

Quote from: Martin Z on June 18, 2023, 07:35:56 PMUnknown tags may be extracted even if they aren't defined (but tags must be defined to be written)
 └ As if I'm understanding this right, I can use this to define the column but list it without any tag mapping(?) and that will let EXIFtool recognise a column but ignore it, yeah?

It depends.  IPTC and EXIF tags do not include a name as part of the tag. For example, the GPSRoll and GPSPitch tags that are defined in the .Example.config, but without the config file, they could only be extracted with the -u (-unknown) option.  And then the results would be 0xd001 and  0xd000.

XMP has the tag name built in, so unknown XMP tags can be extracted by default.  Interestingly, this is how I discovered Victoria's Secret has their own XMP tags (XMP-Victorias_Secret).

QuoteSimilarly, I understand the logic of why AllDates works the way it does, but part of me would have preferred if AllDates would update the FileCreateDate and FileModifyDate

AllDates was created way back in the history of exiftool.  Phil has more and more standardized the way he's organized tag since then.

QuoteI could use this to override AllDates too right? #sogood!

Yes, but instead I'd suggest giving your shortcut tag a different name.  The early examples Phil gave for user-defined tags and shortcuts was often "MyTAG", and I've just kept that as my standard.


QuoteJust one thing to check though, is the %Image part of %Image::ExifTool::UserDefined::Shortcuts significant?

Image::ExifTool (with a capital T) is the name of the Perl library that the exiftool command line script uses.  And the capital T is a mistake that I've made writing stuff before, so I always have to make sure of it.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype