Advanced CSV Import/Export (Windows)

Started by Martin Z, April 10, 2023, 09:08:29 PM

Previous topic - Next topic

Martin Z

Hi Phil, StarGeek, Team,

I have been doing some deeper research/testing using EXIFtool to import/export metadata via CSV files (on Windows) and wondered if you could please help me on a few points...



1. Selective file/property updating

Scenario / Context
  • I have 100x 1GB video files in a folder
  • I use EXIFtool -csv *.mp4 >Metadata.csv to export the metadata for these files to a CSV file
  • I open the file in Excel, notice say 3x files that have a wrong title so amend the CSV file
  • To update the metadata in the files, I pass the CSV back with EXIFtool -csv=Metadata.csv *.mp4
  • In testing the above it looks like EXIFtool will take the CSV and re-write all files with the metadata supplied in the CSV, i.e. in this case it will write 100GB of files even though only 3 files need changes written / 97% of the files have no changes...

❓  Is that the intended behaviour? (not complaining, just checking I am not doing something wrong etc)

❓  Is there a switch for EXIFtool to 'skip if identical', or something like 'check changes before writing', etc?

I tried generating a minimised ('changes only') CSV and passing this to EXIFtool, however this made EXIFtool generate 97 errors for files in the directory that weren't in the CSV. I was able to supress this with... EXIFtool -q -q -csv=changes-only.csv *.mp4 however, while this mainly does the job I am conscious that this supress ALL output from EXIFtool, including other 'useful' errors like invalid column names, metadata errors, etc

❓  Is there an option to supress 'file not found' errors only but still generate other errors, and even success messages? (I tried using -m and -q (single) however these both still generated the 97 file errors)



2. Retaining custom tag groups

Scenario / Context
I saw that EXIFtool does not write some file properties (namely the "Xtra" tags flagged to "Avoid"). However as documented on the Microsoft#Xtra page, these can be written if they are targeted explicitly (i.e. with the group name).

I was pleased to confirm that after a little trial and error, if I named my columns as shown below, then EXIFtool would then update the corresponding properties when importing the CSV file...

SourceFile | Title       | Microsoft:Category | Microsoft:EncodedBy | SharedUserRating
-----------|-------------|--------------------|---------------------|-----------------
File1.mp4  | My movie    | Home videos        | Martin              | 99
File2.mp4  | Bob's movie | Other              | Bob                 | 1

So, in order to keep everything aligned, I tried to extract/generate the same column/CSV headings initially, using...

EXIFtool -csv -Title -Microsoft:Category -Microsoft:EncodedBy -SharedUserRating *.mp4 >Metadata.csv
... but noticed that EXIFtool dropped the tag group in the generated CSV, i.e. ...

SourceFile | Title       | Category           | EncodedBy           | SharedUserRating
-----------|-------------|--------------------|---------------------|-----------------
File1.mp4  | My movie    | Home videos        | Martin              | 99
File2.mp4  |             | Other              | Bob                 | 1

... which means if I update/return this CSV, as the groups are no longer explicitly targeted, EXIFtool will now "Avoid" them and won't update values for the Category or EncodedBy columns.

❓ Is there a way to make EXIFtool persist the group names in the CSV headers if they are specified (or some other way I can achieve this result)?



3. Misc / Other

❓ How do I specify a value to be deleted in the CSV?
-- i.e. using the CSV table above as an example, there is no title for file2.mp4... If file2.mp4 currently has some junk/incorrect value for title and I want to delete this, how do I do that (in testing, EXIFtool seems to skip/ignore that property if the cell is empty)

❓ How to specify the 'multi-item string' syntax for columns like Category?
-- in Windows, multiple values are stored as being separated by ; (semi-colon), however when the property is exported by EXIFtool, it writes the value as being comma-separated. The issue is, if the same value is fed back to EXIFtool, it processes the string literally and so the property goes from say 2 values: "Category 1" and "Category 2" to 1 value called "Category 1, Category 2"

❓ Option to ignore custom (i.e. non-metadata) columns in CSV?
-- As part of the CSV "turnaround process" (i.e. export --> amend --> import), I initially added 1-2 "helper columns" to the CSV to help check or pull-in additional data, however EXIFtool (arguably, rightly) flagged that these columns didn't match the names of any valid tags and subsequently failed to process the CSV file at all... I removed the helper columns and EXIFtool processed the CSV normally again, however I would prefer to keep the columns in ideally (e.g. the CSV might be passed to/from additional scripts, etc), is there an option to tell EXIFtool to ignore certain columns and/or a naming convention I can use in the column headers to be ignored?

❓ Option to use literal FileTypeExtension?
-- I found that in my 100x .MP4 files, the majority of videos were actually listed as ".M4V" files in the FileType and FileTypeExtension columns... While I appreciate (I'm assuming) that they may technically be M4V files in terms of the file schema or encoding format (or whatever), in this case it would be handy to get EXIFtool so export the literal filetype/extension (i.e. .MP4 rather than .M4V) -- is this possible?



Right, that's probably enough for the moment (am nothing if not detailed :))
-- Joking aside though, thanks in advance for your help!

StarGeek

It probably would have been best to make these separate posts, as it will time to answer all of this.  But I'm going to jump in on it.  It'll be a bit before my actual posts pops up.
* 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).

StarGeek

#2
Quote from: Martin Z on April 10, 2023, 09:08:29 PM❓  Is that the intended behaviour? (not complaining, just checking I am not doing something wrong etc)

Yes.  A csv file is no different than listing a command for every file in the list, or doing something like
exiftool -r -Title="New Title" /path/to/lots/of/files
That's the simplified version, at least.

Quote❓  Is there a switch for EXIFtool to 'skip if identical', or something like 'check changes before writing', etc?

There is the -if option but that wouldn't work with hundreds of files. Phil has a post somewhere here that had some good details on why, but I can't find it atm. Something like because of the way exiftool works and how it can accept a stream of data, it wouldn't know whether it was changed until it had already rewritten the file.  I think FAQ #31 is part of this.

QuoteI tried generating a minimised ('changes only') CSV and passing this to EXIFtool, however this made EXIFtool generate 97 errors for files in the directory that weren't in the CSV.

❓  Is there an option to supress 'file not found' errors only but still generate other errors, and even success messages? (I tried using -m and -q (single) however these both still generated the 97 file errors)

There's no way to suppress a single error message, at least I can't recall one at the moment.  But I think the better option is to reverse this.  If you can generate a list of only the files that need to be changed, you can pass that to exiftool and exiftool will ignore any file in the csv that isn't passed to it.

Example.  The CSV file contains one filename not in the target directory.  The csv file is then used to update only one of the files listed there.
C:\>exiftool -G1 -a -s -Title Y:/!temp/ddd
======== Y:/!temp/ddd/20220323_120000_35.jpg
======== Y:/!temp/ddd/Test3.jpg
[XMP-dc]        Title                          : Title1
======== Y:/!temp/ddd/Test4.jpg
[XMP-dc]        Title                          : Title2
    1 directories scanned
    3 image files read

C:\>type mytest.csv
SourceFile,Title
Y:/!temp/ddd/Test3.jpg,New Title1
Y:/!temp/ddd/Test4.jpg,New Title2
Y:/!temp/ddd/Test5.jpg,New Title3

C:\>exiftool -P -overwrite_original -csv=mytest.csv Y:/!temp/ddd/Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -Title Y:/!temp/ddd
======== Y:/!temp/ddd/20220323_120000_35.jpg
======== Y:/!temp/ddd/Test3.jpg
[XMP-dc]        Title                          : Title1
======== Y:/!temp/ddd/Test4.jpg
[XMP-dc]        Title                          : New Title2
    1 directories scanned
    3 image files read

If you can generate a list of the changed files, you can save it to a text file and pass that directory to exiftool -@ (Argfile) option, or if you want to pipe it in, you could use -@ -

This example uses the Linux/Mac find command to generate a list of files and it then pipes that list directly into exiftool



Quote2. Retaining custom tag groups

❓ Is there a way to make EXIFtool persist the group names in the CSV headers if they are specified
(or some other way I can achieve this result)?

From FAQ #12
    With the -f option, the value of any missing tag is printed as a dash (or the value of the API MissingTagValue option, if set). Without this option, missing tags generate a minor warning and the line in the -p output is not printed. The -m option may be used to ignore minor warnings, which causes these lines to be printed with an empty value for missing tags.


Edit: misread question, see next post


Quote3. Misc / Other
❓ How do I specify a value to be deleted in the CSV?

From the docs on the -csv option
    To force a tag to be deleted, use the -f option and set the value to "-" in the CSV file (or to the MissingTagValue if this API option was used).

There a similar line in FAQ #26

Quote❓ How to specify the 'multi-item string' syntax for columns like Category?

Frome 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

Quote❓ Option to ignore custom (i.e. non-metadata) columns in CSV?

I can't think of any off hand

Quote❓ Option to use literal FileTypeExtension?
-- I found that in my 100x .MP4 files, the majority of videos were actually listed as ".M4V" files in the FileType and FileTypeExtension columns... While I appreciate (I'm assuming) that they may technically be M4V files in terms of the file schema or encoding format (or whatever), in this case it would be handy to get EXIFtool so export the literal filetype/extension (i.e. .MP4 rather than .M4V) -- is this possible?

The only thing I can think of is the -api Filter option, but that is global to all tags, so there might be unexpected results.

Example, where mp4 is replaced by mkv

C:\>exiftool -G1 -a -s -filetype -FileTypeExtension Y:\!temp\Test1.mp4
[File]          FileType                        : MP4
[File]          FileTypeExtension              : mp4

C:\>exiftool -G1 -a -s -filetype -FileTypeExtension Y:\!temp\Test1.mp4 -api "filter=s/^mp4$/mkv/i"
[File]          FileType                        : mkv
[File]          FileTypeExtension              : mkv
* 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).

StarGeek

Quote2. Retaining custom tag groups

❓ Is there a way to make EXIFtool persist the group names in the CSV headers if they are specified
(or some other way I can achieve this result)?

I misread this question.

From the docs on the -csv option
    When exporting a CSV file, the -g or -G option adds group names to the tag headings.

Example:
C:\>exiftool -G -a -csv -DateTimeOriginal -Description y:\!temp\Test4.jpg 
SourceFile,EXIF:DateTimeOriginal,XMP:Description
y:/!temp/Test4.jpg,2023:04:14 12:00:00,Test
* 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).

Martin Z

Hi @StarGeek, thanks for your help on all of the above (and apologies for not getting back you on this sooner!)

In a similar fashion to some of my other replies, below is a quick recap of my original q's + rephrasing/extrapolation of your answer to check that I've understood everything correctly. NB: Most of the below should be straight forward, but sections [3] and [7] have some specific (hopefully) useful info, and questions respectively...

Quote[1] EXIFtool will re-write all files with the metadata supplied in the CSV ...  Is that the intended behaviour?
Yes, but there is a key distinction to be aware of...
- If you run EXIFTool with * then it will update every file in the CSV
- BUT If you run EXIFTool listing specific filenames, it will only update those files listed.
Metadata.csv:100 lines
EXIFtool -csv=Metadata.csv *                        [ 100 files written ]
EXIFtool -csv=Metadata.csv Image1.jpg Movie2.mp4    [   2 files written ]
⬆️ NB: The above 'fix' was extrapolated from the main code-block you provided [omitted for brevity], as always though please let me know if this isn't quite right.

Quote[2] Is there a switch for EXIFtool to 'skip if identical'
Yes, in effect by using an IF clause/parameter
⚠️ HOWEVER Please note that for performance reasons this won't work if you are running EXIFtool over hundreds of files. In that case using something like the proposed 'changes only' CSV file, i.e. do the filtering outside of EXIFtool and then pass EXIFtool just the metadata for the files that need updating.

Quote[3] Is there an option to supress 'file not found' errors only
No, there are no options to filter out/supress specific error messages.
✴️ WORKAROUND 1: Note that in this example the error messages were caused because the command being run (EXIFtool [...] *) runs EXIFtool against all files. If a list of specific filenames had been supplied instead, this would not have generated the missing file error messages
✴️ WORKAROUND 2: You can filter out/supress the specific error messages by using FINDSTR (or GREP in linux?), for example the code below will pass the output of EXIFtool through FINDRTR and filter out any lines that start "(full path..." or "No SourceFile...":
EXIFtool <options> | FINDSTR /V /b "(full path" | FINDSTR /V /B "No SourceFile"
Quote[4] Is there a way to make EXIFtool persist the group names in the CSV headers if they are specified
Yes, use -G

Quote❓ [5] How do I specify a value to be deleted in the CSV?
You can delete values by setting the cell value to - (hyphen) and using the -f option in the command line
(Or to whatever has been specified as the MissingTagValue if using the API)

Quote❓ [6] How to specify the 'multi-item string' syntax for columns like Category?
Use -sep "X", where X = the string used to separate items.


Quote❓ [7] Option to use literal FileTypeExtension?
Thanks for your reply, reading your advice though made me think I may have not been clear what I meant to have tried to re-clarify my issue/question below...

C:\> dir *
Movie1.mp4
Movie2.mp4
Movie3.mp4

C:\> EXIFTool -CSV -ext MP4 * >Metadata.csv
3 files read

C:\> TYPE Metadata.csv
| SourceFile | FileType | FileTypeExtension |
| ---------- | -------- | ----------------- |
| Movie1.mp4 | MP4      | mp4               |
| Movie2.mp4 | M4V      | m4v               |
| Movie3.mp4 | M4V      | m4v               |

⬆️ So, all the files are 'physically' .mp4's but in my sample folder, the majority of them are being reported as .m4v files for some reason.
If using the [-api Filter] option is still the best/only option to make the .mp4 files appear as MP4 in the FileType / FileTypeExtension column, then no problem, but just wanted to check.



QuoteIt probably would have been best to make these separate posts, as it will time to answer all of this.  But I'm going to jump in on it.
Fair does, thanks for your help and apologies for taking up a chunk of your time!.. 'will try and not be so monolithic in future! 👍🏼🙂

StarGeek

Quote from: Martin Z on April 28, 2023, 08:33:26 AM(and apologies for not getting back you on this sooner!)

I hadn't noticed, I was mostly away from the forums for a few days.

Quote
Quote[1] EXIFtool will re-write all files with the metadata supplied in the CSV ...  Is that the intended behaviour?
Yes, but there is a key distinction to be aware of...
- If you run EXIFTool with * then it will update every file in the CSV
- BUT If you run EXIFTool listing specific filenames, it will only update those files listed.

Yes, apologies if I wasn't clear.  The way I think of it is that the CSV file is a lookup table. Exiftool only compares files it is processing to see if they are in the lookup table.  If it is, it is processed according to the CSV file.  If the file is not in the CSV file, exiftool issues a warning.  Exiftool doesn't use the CSV file as a list of files to process.

Quote
Quote[2] Is there a switch for EXIFtool to 'skip if identical'
Yes, in effect by using an IF clause/parameter
⚠️ HOWEVER Please note that for performance reasons this won't work if you are running EXIFtool over hundreds of files. In that case using something like the proposed 'changes only' CSV file, i.e. do the filtering outside of EXIFtool and then pass EXIFtool just the metadata for the files that need updating.

Overall, I'm not a big fan of CSV files because you can't really narrow the scope when you have a lot of different tags that need updating.  But since exiftool will rewrite the whole file anyway, rewriting the same value in addition to the changed one won't really slow down processing that much.

As long as the purpose is to only write new data, not overwrite existing data, for example, adding a GPS coordinate to only the files that don't have one, then the -wm (-writeMode) option can be used.  For example, -wm cg will only create and write new tags and will not overwrite existing ones.

Quote⬆️ So, all the files are 'physically' .mp4's but in my sample folder, the majority of them are being reported as .m4v files for some reason.
If using the [-api Filter] option is still the best/only option to make the .mp4 files appear as MP4 in the FileType / FileTypeExtension column, then no problem, but just wanted to check.

Pretty much, though I probably would just load the csv file into a spreadsheet and find/replace.  Because the -api Filter option is global, doing a substitution there might introduce an error elsewhere in the data.

The other option would be to create a user-defined tag and use that in the 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).

Martin Z

Quote from: StarGeek on April 28, 2023, 03:00:17 PMExiftool doesn't use the CSV file as a list of files to process.
Hmmm, but it does kind-of if you run EXIFtool * though, right?

Admittedly my memory could be fault here, but from the last testing / exploration I thought that EXIFtool essentially did both, as in it would...
[1] Lookup CSV: EXIFtool would warn for all files present in the directory but missing from the CSV, and...
[2] Process CSV as Filelist: EXIFtool would warn for all files referenced in the CSV that were missing from the directory

If the above is wrong / I am mis-remembering, that's fine -- my main objective is just to get myself clearer on how EXIFtool processes things, what warnings it will produce in various situ's, and how to supress these if applicable.


Quote from: StarGeek on April 28, 2023, 03:00:17 PMOverall, I'm not a big fan of CSV files because you can't really narrow the scope when you have a lot of different tags that need updating.
Don't want to get too side-tracked, but thought I would do a sense-check after your comment... Merits and flaws of CSVs aside, could you elaborate (briefly) on what you mean about not being able to narrow down the scope when using a CSV please?... Or put another way, what alternative format would work better / let you do more?

For context, I did consider storing the data in JSON / XML but like you say if EXIFtool writes all values/tags anyway, then it doesn't really matter right?... If I am missing a trick then firstly, shame of me! but also yeah be good to know a better way of storing/processing metadata.


Quote from: StarGeek on April 28, 2023, 03:00:17 PMAs long as the purpose is to only write new data [...] then the -wm (-writeMode) option can be used.
OK cool, I probably can't confirm if that will be the case right now but will try and bear the -writeMode option in mind, thanks!


Quote from: StarGeek on April 28, 2023, 03:00:17 PMPretty much, though I probably would just load the csv file into a spreadsheet and find/replace
No worries, it is a slight shame (and I do mean slight) as I don't quite know what is 'throwing EXIFtool off' in this instance, as in why it is listing .mp4 files as .m4v ones (although am guessing it is something to do with file's encoding/headers or something) but again ultimately the main goal is to check the options for how far I can bend EXIFtool to make it work the way I want it to, and the point where it probably doesn't make sense to bend it that much / there is a better way...

TLDR - No worries, I am going to be using a master Excel workbook as my main data source anyway - and will take me all of 2 seconds to get the extension directly from the filename column there, so that option ('fixing' in Excel rather than EXIFtool sounds easier and generally better all-round).


PS - I generally use CSVs because of their interoperability with so many other systems and their table-style layout makes integration with Excel and disseminating to end users a doddle. JSON on the other hand, while yes, yes, it may technically be more useful and extensible, in my mind it is still a  devil spawn of a language that causes pain to anyone that tries to use it... Joking aside, while I am not a big fan of JSON, this is mainly driven by having to use it in places where it clearly should not have been used it the way it has been, and this isn't exactly JSON's fault!

StarGeek

Quote from: Martin Z on April 28, 2023, 04:46:25 PM
Quote from: StarGeek on April 28, 2023, 03:00:17 PMExiftool doesn't use the CSV file as a list of files to process.
Hmmm, but it does kind-of if you run EXIFtool * though, right?

Admittedly my memory could be fault here, but from the last testing / exploration I thought that EXIFtool essentially did both, as in it would...
[1] Lookup CSV: EXIFtool would warn for all files present in the directory but missing from the CSV, and...
[2] Process CSV as Filelist: EXIFtool would warn for all files referenced in the CSV that were missing from the directory

Example, one file listed in csv that doesn't exist, and one file in the directory that's not in the csv because of the incorrect name
C:\>exiftool -G1 -a -s -filename -description Y:\!temp\aaaa
======== Y:/!temp/aaaa/Test 01.jpg
[System]        FileName                        : Test 01.jpg
======== Y:/!temp/aaaa/Test 02.jpg
[System]        FileName                        : Test 02.jpg
======== Y:/!temp/aaaa/Test 04.jpg
[System]        FileName                        : Test 04.jpg
======== Y:/!temp/aaaa/Test03.jpg
[System]        FileName                        : Test03.jpg
    1 directories scanned
    4 image files read

C:\>type temp.txt
SourceFile, Description
Y:/!temp/aaaa/Test 01.jpg,File 1
Y:/!temp/aaaa/Test 02.jpg,File 2
Y:/!temp/aaaa/Test 03.jpg,File 3
Y:/!temp/aaaa/Test 04.jpg,File 4
Y:/!temp/aaaa/Test 05.jpg,File 5
C:\>exiftool -P -overwrite_original -csv=temp.txt Y:\!temp\aaaa
No SourceFile 'Y:/!temp/aaaa/Test03.jpg' in imported CSV database
(full path: 'y:/!temp/aaaa/test03.jpg')
    1 directories scanned
    3 image files updated

C:\>exiftool -G1 -a -s -filename -description Y:\!temp\aaaa
======== Y:/!temp/aaaa/Test 01.jpg
[System]        FileName                        : Test 01.jpg
[XMP-dc]        Description                    : File 1
======== Y:/!temp/aaaa/Test 02.jpg
[System]        FileName                        : Test 02.jpg
[XMP-dc]        Description                    : File 2
======== Y:/!temp/aaaa/Test 04.jpg
[System]        FileName                        : Test 04.jpg
[XMP-dc]        Description                    : File 4
======== Y:/!temp/aaaa/Test03.jpg
[System]        FileName                        : Test03.jpg
    1 directories scanned
    4 image files read

The file Test03.jpg throws a warning because it's not in the csv, while Test 05.jpg is listed in the csv but doesn't actually exist and is ignored.

Quotecould you elaborate (briefly) on what you mean about not being able to narrow down the scope when using a CSV please?

Everything earlier in this thread about how all files that have a listing in the csv get updated, whether they need to or not.  You either have to jump through hoops to get a csv with only the changes or have a long -if option covering all possible data that would be changed.

QuoteOr put another way, what alternative format would work better / let you do more?

I stupid overly complex system which I don't recommend for anyone.  I use IMatch to look at images and metadata.  But I don't use it to update the metadata, as it adds a bunch of tags that I don't want in the file, mostly the XMP-xmpMM Media Management tags.  I recognize these have uses in a more professional setting, especially when keeping versions/edits of the same image in sync, but I don't really do much editing.  I'm not very good at it.  So once I filter the files which have metadata I want to change, I copy the files paths to the clipboard and then run exiftool to write the changes.

QuoteFor context, I did consider storing the data in JSON / XML but like you say if EXIFtool writes all values/tags anyway, then it doesn't really matter right?... If I am missing a trick then firstly, shame of me! but also yeah be good to know a better way of storing/processing metadata.

My main rule is to get the metadata into the file.  Once it is in the file, I can make changes later if need be.  And once it's in the file, I can load or reload into Imatch and that's where I view it.  I don't use any external file types as an intermediary.

I do have a significant amount of customization.  Lots of user-defined tags and user-defined shortcuts.  And I use a text substitution program (Texter) to make long and complex commands easier. 



QuoteI don't quite know what is 'throwing EXIFtool off' in this instance, as in why it is listing .mp4 files as .m4v ones (although am guessing it is something to do with file's encoding/headers or something)

I really don't know the difference but there does appear to be differences.  According to ChatGPT
QuoteIn terms of technical specifications, M4V and MP4 files are almost identical, both using the MPEG-4 Part 14 container format to store video and audio data. However, M4V files may also contain additional metadata such as chapter markers and descriptions, which are not typically found in MP4 files.

Also, M4V appears to all DRM protection.
* 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).

Phil Harvey

Quote from: Martin Z on April 28, 2023, 04:46:25 PM[1] Lookup CSV: EXIFtool would warn for all files present in the directory but missing from the CSV, and...

Yes.

Quote[2] Process CSV as Filelist: EXIFtool would warn for all files referenced in the CSV that were missing from the directory

No.

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

Martin Z

#9
Quote from: Phil Harvey on April 30, 2023, 04:56:56 PMProcess CSV as Filelist

Phil: No

Hi Phil and StarGeek, no worries - I must have gotten mixed-up at some point amongst the various testing and constant tweaking of my wrapper scripts I was doing.

Thanks for clarifying! 👍🏼

Martin Z

Hi @StarGeek,

Thanks for the additional follow-up and info, please see responses below...

RE: Elaboration on difficulties narrowing CSV scope (having to use complex IF commands, etc) -- Ah OK, that all makes sense (and know what you mean now), thanks... TBF, the CSV is just an import/export mechanism mostly, I realise it can't store binary data and things (so am guessing -tagsFromFile is generally better) but as long as there are no fundamental flaws in the CSV approach that's cool.

RE: "I stupid overly complex system" -- Oh good, so it's not just me then! 🤣

RE: .. "which I don't recommend for anyone" -- Oh, but why!? It's ENDLESS hours of fun (or 'wasted time' as nay-sayers call it)

RE: "My main rule is to get the metadata into the file"
└  1000% on the same page on this one!.. While I still want to build a 'Master CSV' (or some other kind of metadata database), this is primarily for seeing the metadata stored IN all the files for: [1] a backup in case the metadata is stripped out of the file, and [2] to facilitate bulk changes.
└  For instance, Plex is great and all but one of my sub-goals of this project is to put all the metadata Plex scrapes/collates and then update the source MP4 and other files so that the metadata is stored there directly and doesn't have to be re-discovered every time I re-image my machine or / re-install Plex, etc.

RE: I do have a significant amount of customization.  Lots of *USER-DEFINED TAGS* -- Oooh, so the user-defined bit is really interesting (potentially), is this something you can do though only within EXIF/JPEG files?... If it is something that can be applied universally then would REALLY like to chat more about that (but can pick up offline, or in a separate thread).

RE: MP4 vs. M4v -- Cool, thanks for trying to help pin it down - makes sense.

Side note: Interestingly I started using .M4V files several years ago, specifically because of chapters - but as a bit of a fudge, as in:
- I came across a program called 'Drax' that let you add and edit chapters to video files
- when opening/saving files, the UI filters only .M4V's however you can manually override by searching *.* and then selecting the .MP4 file I wanted to modify
- I found that the extension seemed to make no difference to VLC or any other app, i.e. I could take a MP4-encoded file, add chapters to it, save/encode it as .M4V, then rename it back to .MP4 and VLC played it fine and read the chapters fine.
- Similarly, I could take an .MP4, rename it to .M4V (without changing a byte of data) and that was also fine
- I phased out of doing this a while back and now just use .MP4 extensions for everything but it was interesting at least.


As usual, thanks for all your help and time! 👍🏼

StarGeek

Quote from: Martin Z on May 13, 2023, 10:34:58 AMRE: I do have a significant amount of customization.  Lots of *USER-DEFINED TAGS* -- Oooh, so the user-defined bit is really interesting (potentially), is this something you can do though only within EXIF/JPEG files?

It depends upon what the config is designed to do.  Some examples
FacesNotInKeywords - This tag checks to make sure that any region names is duplicated in Subject/Keywords. I usually run Imatch's facial recognition on new images that I take and confirm who is in the image.  The actual tagging of the files is done separately.  this tag will compare them and flag any files that I might have missed tagging.  But, the thing is, I don't run a command to check this.  This tag is called from another user defined tag...

MyMissingTags - ...which is this one.  I have certain tags I want set in my files.  This tag checks 44 other tags to make sure I have filled them out correctly.  This one calls FacesNotInKeywords and lets me know if it needs work.

There are also quite a few that are basically legacy/deprecated tags.  For example, at one time, a lot of images I was collecting from the net had equal signs at the end of lines in the Caption-Abstract/Description tags.  I had created tags which would strip these away.  Now, this can be done with advanced formatting, but that wasn't possible when I created them.  Similar situation with a bunch of tags which can be replaced by the NoDups helper function.  I really do need to clean some of these out.

Then there are shortcut tags, which amounts to about 35 more. A lot of these are used to synchronize IPTC and XMP.  "MyLat", "MyLong", and "MyAlt" write to the EXIF gps tags and their reference tags, as well as the XMP GPS tags.
* 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).

Martin Z

Hi @StarGeek, thanks for elaborating.

So, just to check I understand then -- you created your own tag (presumably either EXIF:FacesNotInKeywords or XMP:FacesNotInKeywords) you do some processing/checking and then populate this tag with information, save this info into the image file directly which then other EXIF readers and tools can then access when they read the image file?

-- If that's right, then that is VERY cool!... Would love to know more, but am quite busy at the moment (plus I want to limit the amount of your time I take up) so will put it on my list of things to look into at some point. 👍🏼

-- If that's not correct though, just let me know and will leave it for now.

Cheers either way,
Martin

StarGeek

Quote from: Martin Z on May 16, 2023, 11:35:39 AMyou created your own tag (presumably either EXIF:FacesNotInKeywords or XMP:FacesNotInKeywords)

No, it's a Composite tag that isn't embedded.

Quoteyou do some processing/checking and then populate this tag with information, save this info into the image file directly

Usually not much on the command line in this case. I go into IMatch, double check the tagging and then write the Keywords/Subject from there.

Quotewhich then other EXIF readers and tools can then access when they read the image file?

The data will get written to the standard locations.  I always discourage creating your own tags because no other program beside exiftool (and exiv2) will be able to read them.  As an example, in this thread, the poster was creating their own people in image tag in the EXIF group.  The second code block shows that without the config file, exiftool won't display it by default, only with the -u (-unknown) option.  And even then, because tag names are not stored in EXIF and IPTC, all that is returned is the location, in this case Exif_0xd000

If creating your own tag is a necessity for some reason, it is always best to create them in XMP, as the tag name is included.
* 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).