ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Andreas on February 22, 2012, 12:52:31 PM

Title: Problems with -FileName and case conversion
Post by: Andreas on February 22, 2012, 12:52:31 PM
I stumbled over a strange error when renaming files.

dir_a contains a number of raw files named by my camera:
$ ls -1 dir_a
   DSC_5839.NEF
   DSC_5840.NEF
   DSC_5844.NEF

$ exiftool -r "-FileName<CreateDate" -d %Y%m_foo_%%-4f.%%le dir_a
    1 directories scanned
    3 image files updated

$ ls -1 dir_a
   201201_foo_5839.nef
   201201_foo_5840.nef
   201201_foo_5844.nef


Thank you Phil, exactly what I hoped for!


Now to dir_b, containing the typical mess of various workflows:
$ ls -1 dir_b
   201201_foo_5840.nef
   201201_foo_5844.NEF
   DSC_5839.NEF

$ exiftool -r "-FileName<CreateDate" -d %Y%m_foo_%%-4f.%%le dir_b
Error: 'dir_b/201201_foo_5844.nef' already exists - dir_b/201201_foo_5844.NEF
    1 directories scanned
    1 image files updated
    1 image files unchanged
    1 files weren't updated due to errors

$ ls -1 dir_b
   201201_foo_5839.nef
   201201_foo_5840.nef
   201201_foo_5844.NEF


All files were succesfully renamed but when it comes to the case conversion things get strange. Being on a Mac OS Extended filesystem, which is kind of case insensitive, it's not exactly wrong that 'dir_b/201201_foo_5844.nef' already exists after the first step but that should not prevent a further name change for the same file.

Does exiftool "see" two files where there is only one? If so, the options -o and -overwrite_original should make a difference, but they don't.

I am lost. Thanks in advance for any light!

- Andreas
Mac OS 10.6.8, exiftool 8.79
Title: Re: Problems with -FileName and case conversion
Post by: Phil Harvey on February 22, 2012, 02:50:08 PM
Hi Andreas,

OS X is a semi-case-sensitive filesystem, which can result in peculiarities like this.  ExifTool won't rename XXX to xxx because according to the filesystem both files already exist (exiftool doesn't know they are the same file, but since the target already exists, it won't overwrite it).  To do this with exiftool would unfortunately require going through a temporary directory:

exiftool -r "-FileName<CreateDate" -d tmp/%Y%m_foo_%%-4f.%%le dir_b
exiftool -directory=dir_b tmp
rmdir tmp


- Phil
Title: Re: Problems with -FileName and case conversion
Post by: Andreas on February 23, 2012, 11:32:54 AM
Hi Phil,

Thank you very much, this works like a charm! I read about giving a directory to -FileName but I didn't realize that that was a solution. I wanted to avoid any (re)writing of the image files at this stage of my script but now I see that we are just linking inodes.

Thanks again for your help.

- Andreas