#1 2011-03-11 19:23

Hugo-V
Member
Registered: 2011-03-11
Posts: 2

Some issues with PascalScript: exif date format and THM files

Hello.

When I started with taking digital pictures in a bigger quantity, I found ReNamer as the most flexible and therefore the most needful tool. In the beginning were a handful "normal" rules and a 3-liner of PascalScript to "uppercase" a portion of the new name. Meanwhile ReNamer is "abused" as a terrific GUI to a little 300-liner, which gets the filedate from different sources, depending on which one is available. This includes checking for compatibility and plausibility, calculating a hashcode, creating of a short unique picturenumber for distributing and combining everything in a new filename.

While I worked on that script I stumbled into some obstacles, that caused some workarounds to be written. It's the nature of workarounds to be not as smooth as straight forward solutions. I was looking through the Wiki and the forum, but I found nothing that addressed my problems. Maybe someone can point me into the right direction, if I missed something.

A)
When extracting the Exif_Date-tag Renamer presents the result in the format defined in the settings. Unfortunately it is not possible to change this. You can't define a script internal format and you have no access to the settings (store actual value, set needed value, restore previous value). Well you could read the config file - but changing it and starting another instance of ReNamer from inside a PascalScript isn't a real solution, is it? So you might stick to the given format string and have to use an external program - even if ReNamer could do the job. Is there any sophisticated trick to overcome this limitation?

BTW, although it is a little bit difficult to handle, I prefer Phil Harveys ExifTool as the external program. It is undoubtedly the most powerful tool, when it comes to metatags - like ReNamer at filenames. wink
Compared to Exiv2 it reduces the necessary lines extremely, because you can declare the format of its output:

...
  ExternalExifPrgPath = 'A:\path to ExifTool directory\ExifTool.exe';
  ExternalExifPrgParameter = '-d "%Y-%m-%d-%H-%M-%S"
      -p "$dateTimeOriginal" -f -m -q -q'; // 2x -q is correct
 ...

  if ExecConsoleApp('"' + ExternalExifPrgPath + '" '
      + ExternalExifPrgParameter + ' "' + Filepath
      + '"', ExternalExifPrgResult) = 0 then ... ;
 ...

Or just one line, if you are an "extreme hardcoder" wink :

...
  if ExecConsoleApp('"A:\path to ExifTool directory\ExifTool.exe" -d "%Y-%m-%d-%H-%M-%S" -p "$dateTimeOriginal" -f -m -q -q "' + Filepath + '"', ExifToolResult) = 0 then ... ;
 ...

(Be careful, when wrapping the lines - take care of the spaces, do not loose them. Keep the commandline character limit in mind.)

B)
Canon Cameras write a thumbnail (.THM) together with a RAW-file (.CRW, .CR2). ReNamer is not designed as a metatag specialist; so I wouldn't expect it to retrieve information from the RAW-files. On the other hand it could easily read the THMs. These are perfect JPEG-files and the only thing that prevents their usage is the extension. You have to really change the extension (a preview with an appropriate rule is not enough), extract the metatag and really reset the extension. Is there an undocumented quicker way to get that info? If not, I'd like to suggest a commandline switch and/or a setting to enable unusual extensions.


And now for something completely different.
A lot of the lines in my script are comments. Does it increase the performance of PascalScript, if I take them out? This is what I would expect from an interpreter. Or gives the "Try to Compile"-button a hint to a kind of "On Demand"-compilation where comments don't matter. If "yes", is this done once at the start of a preview or with each single file?

TIA and have a nice weekend.
Hugo-V

Offline

#2 2011-03-12 09:04

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Some issues with PascalScript: exif date format and THM files

For changing the format of a date, I sometime do this...

StringDateName := ReplaceRegEx(StringDateName, '(\d{4})-(\d{2})-(\d{2}) (\d{2}).(\d{2}).(\d{2})', '$1-$2-$3-$4-$5-$6', False, True);

I don't know if it's valid for you...


And about the second thing, I don't know if i understood you correctly but, I think you were talking about something like this:

var
    CurrentExt, MetaTagPath, MetaTag: WideString;

begin
    CurrentExt := WideExtractFileExt(FilePath);
    
    // Check if it is a RAW file
    If (WideSameText(CurrentExt, '.crw') or WideSameText(CurrentExt, '.cr2')) then
        // If RAW get the *.tmp path
        MetaTagPath := WideStripExtension(FilePath) + '.tmp'
    else
        // If not RAW use own path
        MetaTagPath := FilePath;
    
    MetaTag := CalculateMetaTag(MetaTagPath, 'EXIF_Date');
    If (MetaTag<>'') then FileName := MetaTag + ' ' + FileName;
end.

And about the last thing just don't know anything tongue

Last edited by SafetyCar (2011-03-12 09:16)


If this software has helped you, consider getting your pro version. :)

Offline

#3 2011-03-12 14:45

Hugo-V
Member
Registered: 2011-03-11
Posts: 2

Re: Some issues with PascalScript: exif date format and THM files

@SafetyCar: Thank you for trying. You're close, but not close enough.

I'm afraid I have to explain my problems in a different way.

A)
To declare the format for all dates that are returned form metatags you use the menu "Settings->Meta Tags->Date Format". This string is used with all calls of metatags from all rules - including PascalScript. If you put in only the word "blurp", all dates are represented just by "blurp". As it's easily seen there is nothing to reformat, because "blurp" contains no useful information about a date. So it is not possible to write a script, that's independent from the settings.

You could get the actual formatstring by reading the ReNamer.ini-file and determine how to reformat the result of a metatag call. But that won't help, if the string is "blurp". It is absolutly necessary to get access (read AND write) to this string while ReNamer is running. It would help to have a MetaTagDateFormatString-variable (like the FileName-variable) that is connected to or independet from the settings - whatever is easier to implement - which rules the output of metatag calls. Or is there already a way I missed?

B)
As far as I interpret Denis' statement there is no EXIF-support to RAW-files in ReNamer. That's understandable, because this is a wide area, which is impossible to cover. But there is EXIF-support for JPG-files. And this means, there could be support for Canon-THM-files, because these are 100% JPG-files - only with the "wrong" extension. ReNamer just refuses to read from them. You can circumvent this barrier by renaming a THM-file - if it is not located on a writeonly medium. The renaming has to be done real on the medium. It is not sufficient to have the needed rules defined. Although most of the PascalScript functions work immediately during the preview (which can be fatal), the goal is to not touch anything physical before the final name is assembled. That is why I'd like to see some switch/option/parameter to allow a "wrong" extension. What also would be helpful, is the use of the "binary signature" instead of permitting by extension.

BTW, by simply stripping the first 124 bytes of a PMP-file (used by early Sony digital cameras such as the DSC-F1 released in 1996) it becomes also a JPG-file. (FYI: The author of the program "Stamp" (a very specialized renaming tool) provides some information: http://www.klingebiel.com/tempest/hd/pmp.html) But converting isn't the topic here. wink

Greetz,
Hugo-V

Last edited by Hugo-V (2011-03-13 00:13)

Offline

Board footer

Powered by FluxBB