Don't create, just modify

Started by openskies2009, March 23, 2017, 03:37:28 PM

Previous topic - Next topic

openskies2009

I have more then fifty thousand photos and video that have been tagged with Mac OS. When I run exiftool, it re-writes the entire file, some of which are gigibytes in size making it a long long process. Is there anyway just to touch the metadata and leave the file as is, making the time for exiftool to complete shorter?
Here's what I got

exiftool -r -use MWG -overwrite_original_in_place -addTagsFromFile @ '-Keywords+<mditemusertags' '/Volumes/Backup/SMC Media Backup/Sonrise'

Hayo Baan

No, exiftool always rewrites the whole file when a change has been made to the file metadata. Not only is this by design (exiftool also reorders the metadata), how else would you cope with changes that modify the length of the data?

That said, if your files are on a fast disk, things should be fairly quick anyway (only about twice the time of reading all the data).
Hayo Baan – Photography
Web: www.hayobaan.nl

openskies2009

Okay, thank you for your quick response.
Makes sense.
I thought it maybe wrote the hidden EXIF metadata file, but I guess it embeds it in the file.

StarGeek

If you use a program such as Lightroom or darktable, you could write to the XMP sidecar 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

Stephen Marsh

I can't recall why I started using/preferring -overwrite_original_in_place rather than -overwrite_original ... perhaps it was due to the nature of the -P (-preserve) command?

From the ExifTool Application Documentation (http://www.exiftool.org/exiftool_pod.html)

Quote-overwrite_original                   Overwrite original by renaming tmp file
-overwrite_original_in_place     Overwrite original by copying tmp file

-overwrite_original
Overwrite the original FILE (instead of preserving it by adding _original to the file name) when writing information to an image. Caution: This option should only be used if you already have separate backup copies of your image files. The overwrite is implemented by renaming a temporary file to replace the original. This deletes the original file and replaces it with the edited version in a single operation. When combined with -o, this option causes the original file to be deleted if the output file was successfully written (ie. the file is moved instead of copied).

-overwrite_original_in_place
Similar to -overwrite_original except that an extra step is added to allow the original file attributes to be preserved. For example, on a Mac this causes the original file creation date, type, creator, label color, icon, Finder tags and hard links to the file to be preserved (but note that the Mac OS resource fork is always preserved unless specifically deleted with -rsrc:all=). This is implemented by opening the original file in update mode and replacing its data with a copy of a temporary file before deleting the temporary. The extra step results in slower performance, so the -overwrite_original option should be used instead unless necessary.

So, perhaps compare both methods on some large test files, if you are happy with the results of -overwrite_original then this could be faster.

Martin314

Quote from: Hayo Baan on March 23, 2017, 03:51:48 PM
No, exiftool always rewrites the whole file when a change has been made to the file metadata. Not only is this by design (exiftool also reorders the metadata), how else would you cope with changes that modify the length of the data?

Wait, really?  Wow, I always just assumed that "overwrite in place" was smarter than that.  There are many circumstances in which you could overwrite in place without rewriting a significant part of the file, such as EXIF timestamps.  I thought in some other cases new tags could be added at the end of the file, which would only require overwriting a few bytes and an append.  I know there exist other utilities which in certain circumstances only touch a few bytes of the file.

Quote from: Hayo Baan on March 23, 2017, 03:51:48 PM
That said, if your files are on a fast disk, things should be fairly quick anyway (only about twice the time of reading all the data).

My use case is concerned about rewriting files because it's happening on an external SD card.  I want to make changes to the original before I send it to all the places it needs to go.  But now my SD card is going to wear out at least twice as fast due to double the writing!

StarGeek

Quote from: Martin314 on January 13, 2020, 01:39:38 PMThere are many circumstances in which you could overwrite in place without rewriting a significant part of the file, such as EXIF timestamps.

One danger of that is the possiblity corrupting the entire file should there be some interruption in power.  Something I've had happen.  Especially with Windows 10 aggressive reboot for updates regardless of what else you might be doing.  Had that happen as well.

QuoteI thought in some other cases new tags could be added at the end of the file, which would only require overwriting a few bytes and an append.  I know there exist other utilities which in certain circumstances only touch a few bytes of the file.

There are programs that do things like this, but that locks you into that program.  For example, the Fotostation group and the AFCP group do that.  The problem is that most other programs don't even recognize the existence of these and may truncate the trailing data.  I lost a lot of data from some images that had these trailing tags before I realized what had happened.
"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