Problem renaming files stored on Apple APFS file system

Started by sinclairql, February 21, 2022, 05:34:46 PM

Previous topic - Next topic

sinclairql

Digital environment:

  Apple macOS Monterey 12.2.1
  ExifTools 12.30
  Lightroom Classic 11.2 Release

  Panasonic RAW files (RW2)

Command:  exiftool -d JOL%Y-%m-%d%%+.3nc.%%le "-filename<CreateDate" DIRECTORY

Console output:

  $ exiftool -d JOL%Y-%m-%d%%+.3nc.%%le "-filename<CreateDate" /Volumes/Red/Xtra\ Inkommande/Icke\ Inkommande
     1 directories scanned
    59 image files updated
  $

I use ExifTools command to rename my files before they are imported into Lightroom Classic. This has worked fine as long as the files to be renamed were stored on an HFS+ file system. When I use the same command for files stored on an APFS file system the file sequential numbers are completely out of order.

The image "Original files" shows an example of original files, in this case RAW files from a Panasonic Lumix camera.

The next image, "Renamed on HFS+ file system", shows the same files after being renamed and imported into Lightroom. Note the they are sorted after capture time and that  the result is the same order as on the image showing the original files. Also note that the sequential numbering runs from  "001" to "059".

The last image, "Renamed on APFS file system", shows the same files but this time the renaming was performed with the original files stored on an APFS file system. Note that the images are still sorted after capture time and that the result is the same order as on the other two images. However, this time the sequential numbering is completely out or order as seen in the image. ("012", "015", "030", "031", "023", ... , with the last image numbered "001")

The error in the sequential numbering will be identical if the process is repeated with the same collection of RAW images. Renaming the corresponding JPEG images (images where created as RAW+JPEG) will create a similar error but with another numerical  sequence.


StarGeek

I would guess that the file system isn't passing the file list in a sorted order.  I get similar results with files on my drive pool, which has multiple drives treated as a single drive.

Your best bet is to use the -FileOrder option so that exiftool puts them in the correct order before processing.  I have to add -fileorder SubSecDateTimeOriginal so that files are sorted properly.
* 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).

sinclairql

Thank you very much for your suggestion!

I added "-fileOrder DateTimeOriginal" to my command:

exiftool -d JOL%Y-%m-%d%%+.3nc.%%le "-filename<CreateDate" -fileOrder DateTimeOriginal "$PICTUREDIR"

Now all images are renamed with sequence numbers following the time of capture.

An alternate tag could be "SubSecDateTimeOriginal" but since the files from my Panasonic GX7 contains the "DateTimeOriginal" tag only I stick with that one for now.

Files from the newer Panasonic GX9 and LX100 Mk II contains both "DateTimeOriginal" and "SubSecDateTimeOriginal" tags.

StarGeek

The SubSecDateTimeOriginal tag is a Composite tag that exiftool creates on the fly by combining the DateTimeOriginal, SubSecTimeOriginal, and OffsetTimeOriginal tags, if they exist.  The SubSecTimeOriginal tag is created by cameras that keep track of time with more accuracy than 1 second and OffsetTimeOriginal is the time zone if it is recorded.  If you're camera takes burst pictures of more than one/second, you would want to use SubSecDateTimeOriginal, otherwise either that or DateTimeOriginal would be fine.
* 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).

sinclairql

Thank you for clarifying!

For the case with images from cameras with different capabilities you must choose a tag present in all image files.

E.g., exiftool output from the Panasonic GX7 contains only the DateTimeOriginal tag while files from the newer Panasonic GX9 contains both DateTimeOriginal and SubSecTimeOriginal tags.

If you use

  exiftool -d JOL%Y-%m-%d%%+.3nc.%%le "-filename<CreateDate" -fileOrder SubSecDateTimeOriginal "$PICTUREDIR"

the result will be one sequence with all files from the GX9 and another sequence with the files from the GX7. This is exactly what should happen according to the manual.

Using the common DateTimeOriginal tag instead creates one sequence with all files sorted according to the time of origin. This is convenient if you have images from both these cameras and at least 1 second between images: put all image files in the same directory and create a collection of images, with correct sequence numbers, using a single command.

Exiftool is a very useful program!

StarGeek

Quote from: sinclairql on February 23, 2022, 05:04:17 PM
For the case with images from cameras with different capabilities you must choose a tag present in all image files.

You can choose multiple tags.  See note #1 under the -TAG[+-^]=[VALUE] option.  For example, you could use

exiftool -d JOL%Y-%m-%d%%+.3nc.%%le "-filename<CreateDate" "-filename<DateTimeOriginal" -fileOrder SubSecDateTimeOriginal /path/to/files/

And if DateTimeOriginal doesn't exist, it will fall back and use CreateDate instead.
* 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).

sinclairql

The possibility to use multiple tags makes it even better.

Unfortunately your suggested command line will create one sequence with all files from the GX9 and another sequence with the files from the GX7:

exiftool -d JOL%Y-%m-%d%%+.3nc.%%le "-filename<CreateDate" "-filename<DateTimeOriginal" -fileOrder SubSecDateTimeOriginal /path/to/files/

Instead I used the following command line

exiftool -d JOL%Y-%m-%d%%+.3nc.%%le "-filename<CreateDate" -fileOrder DateTimeOriginal -fileOrder SubSecDateTimeOriginal  path/to/files/

which resulted in the desired output: all files sorted according to DateTimeOriginal and numbered in a common sequence.

Thank you for helping me to use ExifTools even more effective than previously!

Phil Harvey

I think there is a cut-n-paste error with your commands.  They look the same to me.

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

sinclairql

I assume you have my last post in view.

The first command use the options -filename, -filename and -fileOrder.

The second command use the options -filename, -fileOrder and -fileOrder.

As stated before, this will be very useful for me!

Thank you for a great tool!
     
      /Johan Landin, Gothenburg Sweden (AKA sinclairql)

Phil Harvey

Ah, right.  Changed one -filename to -fileOrder.  Missed that.

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