#11 2018-08-27 18:02

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 898

Re: ReNamer - RAW Version?

Hi Thomas, could you write more descriptive please?


Thomas wrote: >>I read a lot about regex,
That is the part we will do for you.
Would be better if we would have an example *.cr2 file from you,
but the output with the wanted information from 'exiv2.exe' might be sufficient.


Thomas wrote: >>The second solution
What do you mean? The PowerShell script? What did not work exactly?
But forget that for now, we will concentrate on ReNamer and PascalScript.


Thomas wrote: >>the output was generated.
And where is now the output for your wanted "[EXIF_Model]" information?
Is the line "Camera model    : Canon PowerShot G10" what you want to have for your file name?

If yes, then I have modified the script from http://www.den4b.com/wiki/ReNamer:Scripts:Exiv2 for you:


const
  //The command line to get the output with the wanted information:
  EXE = 'exiv2.exe'; 

  //Wanted information here is "Camera model    : xyz" 

  //RegEx pattern for wanted information:
  TAG = 'Camera model\s*\:\s*(.*?)[\r\n]'; 
 
var
  Command, Output: String;
  Matches: TWideStringArray;  
 
begin
  Command := EXE+' "'+FilePath+'"';
  if ExecConsoleApp(Command, Output) = 0 then
  begin
    Matches := SubMatchesRegEx(Output, TAG, False);
    if Length(Matches) > 0 then
      FileName := Matches[0] + WideExtractFileExt(FileName);
  end;
end.


Untested because of no *.cr2 file at hand

And the string "Canon PowerShot G10" could be cut down too, if you tell us what you want.



HTH?


For more help and how-to's  read our fine Wiki.
If ReNamer had helped you, please donate a coin to Denis or buy a Pro license for commercial use. (Lite vs Pro)

Offline

#12 2018-08-28 12:55

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 2,659

Re: ReNamer - RAW Version?

Thomas Magnum wrote:

den4b:
I tried it, but with your code nothing happens to the name. If I run the command "exiv2 -Pt -K Exif.Image.Model test.CR" the output was generated. Only if I use it in a "pascal script" it won't work.

I have just tried again and it works fine with ReNamer 6.9, exiv2 0.26, script as in the previous post, and a sample CR2 image shot with Canon PowerShot G10. Sample image downloaded from http://www.rawsamples.ch/index.php/en/canon.

You should try again with an isolated portable version of ReNamer and a single renaming rule. There appears to be something that you are missing or doing differently, but it is not clear from your description. See screenshots below.

renamer-and-exiv-with-sample-cr2-image.png

renamer-and-exiv-in-same-folder.png

Offline

#13 2018-08-31 11:04

Thomas Magnum
Member
Registered: 2018-08-22
Posts: 6

Re: ReNamer - RAW Version?

Hello,

ok, I started from scratch and did everythink following den4b's advice. With the result it works!
Now if I combined both scripts (Date nd Time and the Model)  the Name would be change from:

"test.CR2" to: "Canon PowerShot G10  [2018-08-11]-[19-18-42] - .CR2"

For this I changed the "Date and Time Scrit to get rid of the initial script.
from:

var
  DateTime: TDateTime;

begin
  DateTime := FileTimeModified(FilePath);
  FileName := WideExtractBaseName(FileName) +
    FormatDateTime(' (dd-mmm-yyyy)', DateTime) +
    WideExtractFileExt(FileName);
end.

to:

var
  DateTime: TDateTime;

begin
  DateTime := FileTimeModified(FilePath);
  FileName := FormatDateTime(' [yyyy-mm-dd]-[hh-mm-ss] - ', DateTime) +
    WideExtractFileExt(FileName);
end.

The last question is how can I change the order of the name? My final result should be:

"[2018-08-11]-[19-18-42] - [Canon PowerShot G10] 001.CR2".

The part to add add a number is clear fo me (Serialize), but I dont know how to change and format the the order. I guess this should be part of the pascal script.

Thomas

Offline

#14 2018-09-01 09:28

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 2,659

Re: ReNamer - RAW Version?

You could rearrange it after the fact, using Rearrange or Regular Expression rule. But it may be better to just adjust the script to insert the camera model tag in a different way.

Find the last line in the script:

FileName := UnicodeOutput + ' ' + FileName;

And change it to:

FileName := WideExtractBaseName(FileName) + UnicodeOutput + WideExtractFileExt(FileName);

This will insert the tag as suffix (before file extension) instead of as prefix.

By the way, if could also insert the last modified date using the Insert rule with ":File_DateModified:" meta tag, instead of using a script. The date format can be adjusted in the Settings > Meta Tags. That is just an alternative way.

Offline

#15 2018-09-02 10:45

Thomas Magnum
Member
Registered: 2018-08-22
Posts: 6

Re: ReNamer - RAW Version?

Hello den4b,

now I am close to my wish, thank you so for.
One last question. How can I format the String?

I now get this filename (including my third rule for serealizing):

 [2018-08-11]-[19-18-42] - Canon PowerShot G1001.CR2

I now want to format the part "Canon PowerShot G10" to "[Canon PowerShot G10] - ".
How can I add this to the script? I tried several versions from the formating part of the "Date / Time" script, but this is more try and error then testig with a systematic approach.

I would appreciate your help.

Your hint regarding the modify date I had found at the begining of my testing, but it only works for *.jpg files.

Best regards, Thomas

Offline

#16 2018-09-03 13:17

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 2,659

Re: ReNamer - RAW Version?

Thomas Magnum wrote:

I now want to format the part "Canon PowerShot G10" to "[Canon PowerShot G10] - ".

Change this line:

FileName := WideExtractBaseName(FileName) + UnicodeOutput + WideExtractFileExt(FileName);

To:

FileName := WideExtractBaseName(FileName) + '[' + UnicodeOutput + ']' + WideExtractFileExt(FileName);

The trailing dash can be added in the script (similar to the above), or as a separate Insert rule for a better readability.

Thomas Magnum wrote:

Your hint regarding the modify date I had found at the begining of my testing, but it only works for *.jpg files.

The last modified time is available for all files, it can be accessed via ":File_DateModified:" meta tag. You must have a used a different meta tag, which is available only for *.jpg files.

Offline

Board footer

Powered by FluxBB