ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: kalagani on February 10, 2015, 04:24:36 PM

Title: Exiftool replaces symlink with the linked source file
Post by: kalagani on February 10, 2015, 04:24:36 PM
Hello Phil,

I want to write metadata on a source file using the symlink to it!
So, I am using exiftool directly on the symbolic file

I was thinking metadata will be write on the source file by exiftool!
But no, exiftool removed the symlink and replaced it with a copy of the source file, then wrote metadata in this copy!

I do not know, if it is a exiftool bug or if I do a bad command!

What are you thinking about this?

Thanks.

Kalagani
PS:
1) before using exiftool, ll showing the symlink
lrwxrwxrwx 1 patrick patrick    198 févr.  7 19:24 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif -> ../../boitesDiapos/boite1995-06-xt/1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif

2) executing the command
exiftool -P -overwrite_original -v -exif:Artist=Michel 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif
======== 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif
Rewriting 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif...
  Editing tags in: IFD0 TIFF
  FileType = TIFF
  MIMEType = image/tiff
  ExifByteOrder = II
  Rewriting IFD0
  Rewriting ExifIFD
  Rewriting MakerNoteNikon
  Rewriting PreviewIFD
  Rewriting NikonScanIFD
  Rewriting ICC_Profile
  Rewriting IFD1
  Copying 2 image data blocks
    1 image files updated

3) now after executing, symlink is replaced by a copy from original
-rw-rw-r-- 1 patrick patrick 122469628 janv. 18 17:56 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif

4) metadata is OK in this copy
exiftool -g -*:* 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif |grep Michel
Artist                          : Michel
while not in the source
exiftool -g -*:* ../../boitesDiapos/boite1995-06-xt/1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif |grep Michel

5) I am using the Mageia4 distribution Linux, with
uname -a
Linux localhost.localdomain 3.14.27-server-1.mga4 #1 SMP Sun Dec 21 22:58:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

rpm -qa |grep -i exiftool
perl-Image-ExifTool-9.270.0-2.mga4

perl -v
This is perl 5, version 18, subversion 1 (v5.18.1) built for x86_64-linux-thread-multi
Title: Re: Exiftool replaces symlink with the linked source file
Post by: Xlnt on February 10, 2015, 04:47:18 PM
Using -overwrite_original_in_place (instead of -overwrite_original) should fix this.


    -overwrite_original
         ... 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. ...

    -overwrite_original_in_place
         ... 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. ...


Not tested.
Title: Re: Exiftool replaces symlink with the linked source file
Post by: Phil Harvey on February 10, 2015, 06:18:10 PM
Xlnt is correct.  Try -overwrite_original_in_place.

- Phil
Title: Re: Exiftool replaces symlink with the linked source file
Post by: kalagani on February 11, 2015, 04:46:03 AM
Thanks a lot you 2,

I tested and it is OK, now symlink is not replaced using the
/usr/bin/exiftool -P -overwrite_original_in_place -v -exif:Artist=Michel 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif
======== 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif
Rewriting 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif...
  Editing tags in: IFD0 TIFF
  FileType = TIFF
  MIMEType = image/tiff
  ExifByteOrder = II
  Rewriting IFD0
  Rewriting ExifIFD
  Rewriting MakerNoteNikon
  Rewriting PreviewIFD
  Rewriting NikonScanIFD
  Rewriting ICC_Profile
  Rewriting IFD1
  Copying 2 image data blocks
    1 image files updated

the ll command
lrwxrwxrwx 1 patrick patrick    198 févr. 11 10:20 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif -> ../../boitesDiapos/boite1995-06-xt/1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif
and now reading symlink or source file I have the written information
exiftool -g -*:* 1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif |grep Michel
Artist                          : Michel
exiftool -g -*:* ../../boitesDiapos/boite1995-06-xt/1995-06-xt-d_08_PouliciaNoel_JeanLucSuzanneSimonePatrick.tif |grep Michel
Artist                          : Michel


So, I am using a script to write information in several images, is there a side effect, if I replace -overwrite_original with -overwrite_original_in_place
when I have symlinks and real images in a same directory?
Title: Re: Exiftool replaces symlink with the linked source file
Post by: Phil Harvey on February 11, 2015, 07:02:43 AM
The side effects are:

1) Other file attributes may be preserved

2) The processing is slower due to the extra step of copying the temporary file

See the application documentation for details.

- Phil
Title: Re: Exiftool replaces symlink with the linked source file
Post by: kalagani on February 11, 2015, 10:55:23 AM
Thanks Phil,

about the side effect you write in 1) at which file attributes do you think?
I test with a real file and symlinks in a same directory and none attributs seems differents between before or after executing in a loop my script below
...
      /usr/bin/exiftool -P -v -overwrite_original_in_place \
     -exif:Artist="$3" \
     -exif:Copyright="$4" \
     -exif:imagedescription="$2" \
     -iptc:By-Line="$3" \
     -iptc:CopyrightNotice="$4" \
     -iptc:Caption-Abstract="$2" \
     -xmp:Creator="$3" \
     -xmp:Rights="$4" \
     -xmp:description="$2" \
     "$1" &> /dev/null
      if [ $? -ne 0 ] ; then
     echo "$1" >> "$repertoireLog/tableCopyrigthNOK"
      else
     echo "$1" >> "$repertoireLog/tableCopyrigthOK"
#     Renommage à partir métadonnée exif \"DateTimeOriginal\""
     exiftool  "-DateTimeOriginal>FileModifyDate" "$1"
      fi
...
Title: Re: Exiftool replaces symlink with the linked source file
Post by: Phil Harvey on February 11, 2015, 11:07:52 AM
The documentation lists a number of these attributes on Mac systems.  On linux, likely the only difference will be how hard/soft links are handled.

- Phil