Sort on -G column first?

Started by handvprice, January 21, 2024, 06:53:35 PM

Previous topic - Next topic

handvprice

TY for the responses to my earlier question about outputting the command line.

New question: "-sort" seems a little wonky. It properly sorts on the tagname (assuming using -s). But if I also add -G to show the makernotes, it still sorts properly by tagname within each group, but the groups aren't sorted alphabetically.

Also, adding -All results in it sorting by tagname, but now paying no attention to group.

(For now, I'm redirecting output to a txt file, importing into word, sorting, and outputting back to .txt so I can compare the effects of different switches or comparing heic's and jpg's.)

TY in advance.

Phil Harvey

#1
Yes, correct.  With -sort -G the tags are sorted within each group, but the order of the groups is not changed.  And you're right about the behaviour with -all.  I can't recall if that was intended or not... honestly, almost nobody uses the -sort feature.  :P

You can do this if you want the sort to include the group:

exiftool -G FILE | sort

- 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 21, 2024, 09:41:04 PMYou can do this if you want the sort to include the group:

exiftool -G FILE | sort

This will work on Windows as it has a sort command in C:\Windows\System32\.

I think PowerShell will high jack the command into its own Sort-Object cmdlet, which still seems to work.
"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

Testing further, I'm a bit confused about the --sort option.  It says in the docs
QuoteBy default, tags are organized by groups when combined with the -g or -G option, but this grouping may be disabled with --sort.

But I can't see how the sorting is happening with the output. My test file has the File group split up and almost nothing appears to have actually been sorted.

Example
C:\>exiftool -G -s --sort y:\!temp\Test4.jpg
[ExifTool]      ExifToolVersion                 : 12.72
[File]          FileName                        : Test4.jpg
[File]          Directory                       : y:/!temp
[File]          FileSize                        : 451 kB
[File]          FileModifyDate                  : 2024:01:16 12:28:43-08:00
[File]          FileAccessDate                  : 2024:01:21 19:40:26-08:00
[File]          FileCreateDate                  : 2023:12:15 07:53:23-08:00
[File]          FilePermissions                 : -rw-rw-rw-
[File]          FileType                        : JPEG
[File]          FileTypeExtension               : jpg
[File]          MIMEType                        : image/jpeg
[File]          CurrentIPTCDigest               : 7b041c32dffe3d70e4e2f5d6b7f0940d
[IPTC]          Caption-Abstract                : test
[IPTC]          ApplicationRecordVersion        : 4
[XMP]           XMPToolkit                      : Image::ExifTool 12.72
[XMP]           Description                     : Test
[File]          ImageWidth                      : 1749
[File]          ImageHeight                     : 1205
[File]          EncodingProcess                 : Baseline DCT, Huffman coding
[File]          BitsPerSample                   : 8
[File]          ColorComponents                 : 3
[File]          YCbCrSubSampling                : YCbCr4:2:0 (2 2)
[Composite]     ImageSize                       : 1749x1205
[Composite]     Megapixels                      : 2.1
[Composite]     AspectRatio                     : 1749:1205
"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

handvprice

TY both!

Responding to StarGeek, it looks like without any sort switch, there may be a "heirarchy" of groups, Exiftool then File then Quicktime then Exif then MakerNotes then ICC and finally Composite. With -sort, tags are sorted within each group, but group order is same. With --sort, it seems somewhat random.

TY again. Spectacular software, that even the major companies recommend. I'm *so* impressed by the rapid responsiveness, especially by the developer. Can't get that kind of support in *paid* software. So I'm donating some. Thanks.

Phil Harvey

@StarGeek:  With --sort, the sort order is just the order of extraction.  You won't see a big difference with this unless there are tags from 2 same-named groups extracted at different times.

@handvprice:  Thanks for the donation.

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