Author Topic: Migrate file-renaming script from IMatch 3 to IMatch 5  (Read 3531 times)

DavidOfMA

  • Sr. Member
  • **
  • Posts: 253
  • Writer/Photographer/Therapist
Migrate file-renaming script from IMatch 3 to IMatch 5
« on: July 04, 2014, 06:43:05 AM »
I name my files as follows: YYMMDD-HHMMSS-nn-model, where "nn" is a unique number derived from the either the hundredths of a second, if present, or the last two digits of the OID, if hundredths are not present, and "model" is the model name of the camera. I have been trying to see if the file renamer is able to create similar names, but I can't find a way to shorten some of the long names stored in the EXIF. For instance, my Samsung WB60 "model" name is stored as  "SAMSUNG WB650_VLUU WB650)SAMSUNG WB660" instead of just "WB650," which is all I want.

Is there a way to parse a substring out of the long model number? In IMatch 3, I use a set of If...then statements to match what is in the EXIF and then rename the file with the subset I want to use, but I can't see any way to do that with the file renamer.

I have also looked into porting the script I use in IMatch 3 to IMatch 5, but I see that the language is quite different and it's completely unclear even where to start in getting the thing to run. I'm not a programmer, though I have been able to modify existing code to suit my purposes (in this case, the original YYMMD-HHMMSS-nn code came from an existing IMatch 3 script).

Attached is the script I want to convert. Any suggestions on how to proceed are appreciated. Without being able to rename my files, I don't think it makes sense for me to proceed with IMatch 5, which I'd otherwise like to do.

Thanks,
David

[attachment deleted by admin]
« Last Edit: July 04, 2014, 06:48:26 AM by DavidOfMA »

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 28532
Re: Migrate file-renaming script from IMatch 3 to IMatch 5
« Reply #1 on: July 04, 2014, 08:30:50 AM »
The scripting language in IMatch 5 is identical to the scripting language used for IMatch 3, just a improved and updated version. The object model of IMatch 5 has changed in some areas to incorporate all the new features available in IMatch 5. And the step from IMatch 3 to IMatch 5 allowed my to modernize the object model after keeping it stable for almost 10 years.

You can extract parts of variables using the substring variable function.  And many other things. Have you studied the available variable functions in the Variables help topic? For example:

{File.MD.Exif::Main\272\Model\0|substrr:0,4}

extracts the last 4 characters from the modl name.

You can also access the sub seconds and oid with variables. And you can even test if the sub second variable has a value and if not use two digits from the oid. This is all quite easy, check the samples in the Variable help topic, open the Var Toy App so you can try things out. When you have the variable you need, use it in the Renamer. No need to write a script for this.

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1398
  • I'm too damn old to act my age.
Re: Migrate file-renaming script from IMatch 3 to IMatch 5
« Reply #2 on: July 04, 2014, 03:26:17 PM »
David I took a quick look at your script and at first glance it doesn't appear to me like it does anything you can't also do with the standard IMatch renamer.

DavidOfMA

  • Sr. Member
  • **
  • Posts: 253
  • Writer/Photographer/Therapist
Re: Migrate file-renaming script from IMatch 3 to IMatch 5
« Reply #3 on: July 05, 2014, 05:49:35 AM »
What's confusing to me is how I can emulate an if-then-else sequence. Would I just create a series of tests in the file renamer that look at the model number and, for instance, if it's "Panasonic DMC-G1" substitute "DMC-G1," if it's "SAMSUNG WB650_VLUU WB650)SAMSUNG WB660" substitute "WB650," and so on?

And, is there a way to run the renamer automatically on IMatch startup?

Thanks,
David

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 28532
Re: Migrate file-renaming script from IMatch 3 to IMatch 5
« Reply #4 on: July 05, 2014, 07:49:01 AM »
1. Lookup the replace function in the Variables help topic. It allows you to replace one string with another. You can add multiple replace functions, they are processed from left to right. There are samples, and the VarToy app will allow you to try things out.

2. You cannot run the Renamer when IMatch starts. You have first to select the files you want to rename and then press <F2> or <Ctrl>+<F2>.

DavidOfMA

  • Sr. Member
  • **
  • Posts: 253
  • Writer/Photographer/Therapist
Also automatically assign default categories on import?
« Reply #5 on: July 07, 2014, 03:53:58 AM »
Okay, thanks. I'll look into it.

Another thing my startup script does is assign categories based on file name and extension, including the camera make and model number. It looks like IMatch will assign make and model number categories automatically using data-driven categories already set up as sample categories.

Can I also use data-driven categories to assign categories based on file extension? When I import files, I like to assign the categories "Captured" and "Original" to the RAW, DNG, and JPG files I first import, and then also assign "RAW" to the DNG and RAW files. This helps me out later, when I'm filtering images for further processing. I'd prefer not to have to do any of these category assignments manually, but it's not clear to me how to do it with data-driven categories or if that's even possible, given that the extensions are not metadata. I've read the help on data-driven categories and looked for ways to use the file extension, but I can't figure that out.

Thanks,
David

 

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 28532
Re: Migrate file-renaming script from IMatch 3 to IMatch 5
« Reply #6 on: July 07, 2014, 09:08:37 AM »
If you open the data-driven properties for a category, you open the tag selector to choose the tag you want.

And in the Standard Tags, the very first tag right at the top is named File Extension...




[attachment deleted by admin]

DavidOfMA

  • Sr. Member
  • **
  • Posts: 253
  • Writer/Photographer/Therapist
Re: Migrate file-renaming script from IMatch 3 to IMatch 5
« Reply #7 on: July 07, 2014, 05:33:56 PM »
Thanks again. Sorry for such basic questions, but the UI is so different from IMatch 3 that it's been hard to find my way around the program and the Help.