ExifTool Forum

ExifTool => ExifTool GUI => Topic started by: Beholder3 on October 23, 2011, 11:26:03 AM

Title: Beware of leading blanks in filenames
Post by: Beholder3 on October 23, 2011, 11:26:03 AM
Hi Bogdan,

I just spent quite some worried time find a cause of an error and I want to share what I found:

I did import some DNG pictures into Lightroom and changed the filesnames automatically there using a new format.
What I didnt realize (it's not easy to see this on screen in a simple textbox) is that my renaming changed all filenames to start with a leading blank/space character.
This leads to exiftoolGUI to show results in the middle view pane in camera view but nothing at all in the right hand detail pane. Only a cryptic error.
As I checked with commandline exiftool I could see that exiftool itself has no issues and works as normal.

Seems to me there is a small bug in exiftoolGUI...
Title: Re: Beware of leading blanks in filenames
Post by: BogdanH on October 23, 2011, 01:06:49 PM
Hi,
Interesting. You said you've checked with commandline, and there is no problem... I've tried with various files (raw and jpg) and as it seems, there is.

Question for Phil:
Assume I have file " img.jpg" inside c:\aa directory. That is, "c:\aa\ img.jpg" is complete file path (notice, that first character of filename is space character).
Now, if I execute:
exiftool -S "c:\aa\ img.jpg"
-everything is fine.
But if I already "reside" inside c:\aa directory and execute:
exiftool -S " img.jpg"
-exiftool returns "Error opening file".

Mind to comment? Having (needing) blank first character in filename is quite rare, though.

Bogdan
Title: Re: Beware of leading blanks in filenames
Post by: Phil Harvey on October 23, 2011, 02:43:30 PM
Interesting that this hasn't ever come up until now.  This is a bug in ExifTool.  It won't accept a filename with a leading space.  I will fix this in the next release.

Thanks for pointing this out.

- Phil
Title: Re: Beware of leading blanks in filenames
Post by: Beholder3 on October 24, 2011, 02:01:37 AM
Ok, what I did exactly is I dragged/dropped a file (with leading blank) in windows onto the "exiftool(-k).exe" file, which resided in a different directory than the picture file. That worked/works and showed results.

At least it confirmed to me that the metadata were still there and not fully corrupted as I had feared first.
Title: Re: Beware of leading blanks in filenames
Post by: Phil Harvey on October 24, 2011, 07:19:16 AM
If you specify a directory then the leading space isn't a problem.  Even using "./ img.jpg" gets around the problem.  When you drag/drop, I am sure that Windows includes the directory name, which explains why this works.

- Phil
Title: Re: Beware of leading blanks in filenames
Post by: Phil Harvey on October 24, 2011, 09:23:59 AM
I just checked my Perl programming book.  It says:

    In order to open a file with arbitrary weird characters in it,
    it's necessary to protect any leading and trailing whitespace, like this:

        $file =~ s#^(\s)#./$1#;
        open (FOO, "< $file\0");

    But we've never actually seen anyone use that in a script...

Doh.  I will be doing this in ExifTool 8.69.

- Phil