Author Topic: File organization script migration from imatch 3 to 5  (Read 16676 times)

phbee2014

  • New Members
  • *
  • Posts: 19
File organization script migration from imatch 3 to 5
« on: July 06, 2014, 03:24:29 PM »
The biggest challenge that I am facing as a user to switch from imatch 3 to 5 are these scripting language incompatibilities and migration issues. I have more than 20 scripts to convert in a short time. Now here are some difficulties that surfaced immediately:
What is the equivalent of IMIPTCResult, IPTCStream, images, images, ImageBucket as variable type? Probably many others are waiting in queue.
Now, as the user DavidofMA points out is it not possible to have some kind of a tool that will replace automatically those variables, variable types, methods and what not to ease the burden of this conversion task.
Any help will be appreciated.
Thanks.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #1 on: July 06, 2014, 07:10:18 PM »
The scripting engine used by IMatch 5 is compatible with the scripting engine used by IMatch 3.6.0.118 released more than one year ago. This is for the Basic language dialect etc.

The scripting object model in IMatch 5 has changed for the first time in almost 10 years. This step was required, and it may brake some existing scripts. The Beta test phase (almost 12 months) gave uses the chance to convert their scripts as needed. If you did not participate the in the Beta test, you will have to migrate your scripts now, if the functionality provided by your scripts is not available in IMatch 5 anyway.

Quote
I have more than 20 scripts to convert in a short time.

The Beta test for IMatch 5 ran for almost a year. Why did you not participate and converted your scripts without pressure during that year?

Did you read the Script Migration Guide in the help? This should get you started. You'll find it by typing Migrate in the help index and then clicking on the IMatch 3.x scripts entry. The Migration Guide lists the major changes, explains which classes have been replaced etc.  For example, I read there

IPTCStream Retired. Use the Metadata classes instead.

which tells me that IPTCStream is no more and that I have to use the new universal Metadata classes instead. These classes not only handle all metadata supported by IMatch, including IPTC, EXIF, XMP, GPS, PDF in a universal fashion, but also allow you to write not only IPTC but XMP and EXIF as well.
« Last Edit: July 06, 2014, 09:06:46 PM by Mario »

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #2 on: July 06, 2014, 09:05:01 PM »
If you post some specific questions or partial/complete scripts that you're trying to convert, we'll try to help you make the transition.

FWIW if you're like me you may realize you won't need several of the scripts you used to use in IMatch 3 as version 5 does so much more than 3.

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #3 on: July 07, 2014, 07:54:16 AM »
Well participating in a beta test takes also a lot of time. I did not expect that such a dramatic change will take place in scripting. Anyway such a difficulty is in the nature of an upgrade especially if one is dealing with a software product that offers so many possibilities.  Nevertheless I think a possibility could have been offered to the users to continue running their "old" scripts should they wish to do so rather than having them suddenly confronted with a chaotic situation where all scripts stop execution due to one reason or another.
As to specific questions thanks for the offer for help. Here is one:
what should I use instead of "Set actfolder = Application.Database....." to define an active folder?

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #4 on: July 07, 2014, 09:20:57 AM »
Quote
Nevertheless I think a possibility could have been offered to the users to continue running their "old" scripts should they wish to do so rather than having them suddenly confronted with a chaotic situation where all scripts stop execution due to one reason or another.
Since IMatch 5 does not use it's own routines to read and write IPTC but ExifTool, re-building the old IPTCStream object model on top of ExifTool just for one or two users who don't want to move to the more modern and easer Metadata classes would have been pointless and a waste of time. IPTCStream did work only for legacy IPTC anyway - which you should not use anymore, unless absolutely required by your workflow.

I've kept the scripting object model stable for almost 10 years, but for IMatch 5 I have made some breaking changes which may affect some old scripts.  Not many users create their own scripts (I do everything that's possible as an IMatch App myself!), and from these users only some used the IPTCStream classes.

IMatch 5 comes with an exhaustive scripting object model documentation in the IMatch help. The help has many sample snippets you can copy and reuse, and there are also a lot of sample scripts which demonstrate virtually all aspects of the scripting object model for IMatch 5. If you study this info you will have to agree that the refreshed object model is much more consistent and easier to use. Much more powerful, too.

Quote
what should I use instead of "Set actfolder = Application.Database....." to define an active folder?

Such questions are usually directly answered in the scripting editor:



[attachment deleted by admin]

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: File organization script migration from imatch 3 to 5
« Reply #5 on: July 07, 2014, 10:57:04 AM »
Now, as the user DavidofMA points out is it not possible to have some kind of a tool that will replace automatically those variables, variable types, methods and what not to ease the burden of this conversion task.
Any help will be appreciated.

I migrated a number of my scripts.  I developed a set of search and replace commands to do this, so that performing these in sequence did most of the work.  I could try and clean this list up and post it when I'm home towards the end of the month,

But there are some areas that need a complete rethink.  IPTC is one of them.  Attributes to a lesser extent are another.  Usually once you've migrated one script the rest are a lot less work.

But you should take seriously the comments of others than in V5 the for need for scripts is a *lot* less.  Metadata templates can do a lot of the work in V5 that scripts were needed for in V3.6   

DavidOfMA

  • Sr. Member
  • **
  • Posts: 253
  • Writer/Photographer/Therapist
Re: File organization script migration from imatch 3 to 5
« Reply #6 on: July 07, 2014, 05:38:22 PM »
If you have a chance to post your search-and-replace lists, that would be helpful. I use only a few scripts, but I use them all the time, and although I see that I could learn to do what the scripts do in the IMatch 5 way, I have limited time to learn the program and the scripts do in one step what it seems it would take me two or three steps to do, even after I learn how to do the same things in IMatch 5. I'd much rather be up and running in IMatch 5 and then gradually convert to doing things in the new, improved way. Perhaps others who have been using IMatch 3 for a long time feel that way, too.

Thanks,
David

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #7 on: July 07, 2014, 06:28:37 PM »
Some other questions: What should replace the structures such as

'Begin Dialog UserDialog 600,280,"Organize Folders with IPTC"'
'Application.WaitDialogOpen "Renaming and Moving Images...",0,100,True'
'Application.WaitDialogIsCanceled'
'Application.WaitDialogClose'
'Application.WaitDialogSetPercentage'
'Application.WaitDialogSetText'
'db.ParseVariables'

Anote for DavidofMA: I definitely agree with the statement "I'd much rather be up and running in IMatch 5 and then gradually convert to doing things in the new, improved way. Perhaps others who have been using IMatch 3 for a long time feel that way, too."





JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #8 on: July 07, 2014, 07:21:20 PM »
Some other questions: What should replace the structures such as

'Begin Dialog UserDialog 600,280,"Organize Folders with IPTC"'
'Application.WaitDialogOpen "Renaming and Moving Images...",0,100,True'
'Application.WaitDialogIsCanceled'
'Application.WaitDialogClose'
'Application.WaitDialogSetPercentage'
'Application.WaitDialogSetText'
'db.ParseVariables'


The IMatch 3 Wait dialog is now called a progress dialog in version 5.  Below is an example of how you can use it (variable f represents the currently processed file).

Code: [Select]
' Intialize Code
' BEGIN PROGRESS DIALOG SETUP ////////////////////////////////////////////////////////////////////
Dim pd As New IMProgressDialog
pd.Create "Initial Headline Text","2nd line text",0,selection.Count-1,True
' END PROGRESS DIALOG SETUP //////////////////////////////////////////////////////////////////////


' In Loop Code (f. may need to be changed)

' BEGIN PROGRESS DIALOG //////////////////////////////////////////////////////////////////////////
Application.Sleep 100
pd.Headline = "Changing headline text goes here"
pd.Text = "Processing " + f.NameExt
pd.Step
If pd.Canceled Then Goto ScriptShutDown
' END PROGRESS DIALOG ////////////////////////////////////////////////////////////////////////////

' And at the end of the script.

ScriptShutDown:
pd.close


Next is an example of how to parse variables in version 5. This example simply establishes the location of ExifTool by parsing the IMatch {Application.AppFolder} variable.

Code: [Select]
Dim context As New VarContext
Dim ET As String
ET = Chr$(34) & context.Parse("{Application.AppFolder}") & "exiftool.exe" & Chr$(34)


I should note that I, and no doubt Ferdinand and many others, spent countless hours studying the IMatch 5 help on scripting.  Everything you need to know is in there but I understand the need for asking questions too.  You should have seen our questions to Mario during the beta period! ;)

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #9 on: July 07, 2014, 07:31:14 PM »
I should add one more script snippet for the above progress dialog to work.  The following creates a variable called selection that represents the selected files.

Code: [Select]
Dim selection As Files
Set selection = Application.GetFileWindow(imfwtCurrent).SelectedFiles
If selection.Count = 0 Then
MsgBox "Please select at least one file."
set selection = nothing
Exit Sub
End If

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #10 on: July 07, 2014, 07:43:48 PM »
See also the Progress Dialog sample script. It shows an isolated and easy to copy example on how to use the progress dialog class.

I generally recommend that you run each sample script to see what they do.

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #11 on: July 07, 2014, 09:39:07 PM »
Thanks Zeman and Mario. Zeman I ran the first piece of code but it gives an error message saying "not an object reference" and hangs there.
"' Intialize Code
   ' BEGIN PROGRESS DIALOG SETUP ////////////////////////////////////////////////////////////////////
   Dim pd As New IMProgressDialog
   pd.Create "Initial Headline Text","2nd line text",0,selection.Count-1,True
   ' END PROGRESS DIALOG SETUP /"

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #12 on: July 07, 2014, 10:11:10 PM »
That's because IMatch doesn't know what the variable selection is.

You need to put the other snippet of code I posted afterwards ahead of it to define the selection variable.


JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #13 on: July 07, 2014, 10:15:40 PM »
Here is a complete working script that demonstrates the Progress Dialog (the script doesn't actually do anything).

Code: [Select]
Option Explicit


Sub Main

Dim selection As Files
Set selection = Application.GetFileWindow(imfwtCurrent).SelectedFiles
If selection.Count = 0 Then
MsgBox "Please select at least one file."
Set selection = Nothing
Exit Sub
End If

Dim f As File


' BEGIN PROGRESS DIALOG SETUP ////////////////////////////////////////////////////////////////////
Dim pd As New IMProgressDialog
pd.Create "Initial Headline Text","2nd line text",0,selection.Count-1,True
' END PROGRESS DIALOG SETUP //////////////////////////////////////////////////////////////////////


For Each f In selection
' BEGIN PROGRESS DIALOG //////////////////////////////////////////////////////////////////////////
Application.Sleep 300
pd.Headline = "Changing headline text goes here"
pd.Text = "Processing " + f.NameExt
pd.Step
If pd.Canceled Then GoTo ScriptShutDown
' END PROGRESS DIALOG ////////////////////////////////////////////////////////////////////////////
Next

ScriptShutDown:
pd.Close
Set selection = Nothing
Set f = Nothing

End Sub

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #14 on: July 08, 2014, 11:14:51 AM »
OK thanks John.
What exactly should I use to accumulate images in a bucket ie replacement for an image bucket?

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #15 on: July 08, 2014, 02:01:20 PM »
Have you spent a bit time in reading the help yet?

Because when I look at the Script Migration topic, I see:

Quote
ImageBucket Functionality now available in the Files class.

So if you look at the Files class, you will find everything you'll need. It has many exciting methods like AddFile, AddFiles, RemoveFile, RemoveFiles. There are even usage examples right next to the method descriptions...and a demo scripts which shows how to use all these methods:

Quote
See the File and Files sample script and many other sample scripts for usage examples.
« Last Edit: July 08, 2014, 02:04:37 PM by Mario »

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #16 on: July 08, 2014, 04:11:41 PM »
OK thanks John.
What exactly should I use to accumulate images in a bucket ie replacement for an image bucket?

A bucket demo script follows:

Code: [Select]
'#Language "WWB-COM"
Option Explicit

Sub Main
Debug.Clear
Dim selection As Files
Set selection = Application.GetFileWindow(imfwtCurrent).SelectedFiles

If selection Is Nothing Or selection.Count = 0 Then
MsgBox "Please select at least one image first!",vbExclamation, "OOPS!"
Exit Sub
End If

Dim mybucket As New Files

MsgBox "Right now there are " & selection.Count & " files selected." & vbCrLf & vbCrLf & "And " & mybucket.Count & " files in the bucket."

Dim f As File
For Each f In selection
mybucket.AddFile f ' Add the currently focused image to the bucket
Next f

MsgBox "Now there are " & selection.Count & " files selected." & vbCrLf & vbCrLf & "And " & mybucket.Count & " files in the bucket."

Set f = Nothing
Set selection = Nothing
Set mybucket = Nothing
End Sub

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #17 on: July 08, 2014, 06:25:43 PM »
Thanks guys. In fact after writing the post I found out about the files treated as a bucket to accumulate images. But here is another one which has bothered me lately. How do I create a new folder in Imatch provided that I know the whole path. I tried this but it does not work.

Set newFolder = Database.AddFolder (folderMonthPath)

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #18 on: July 08, 2014, 06:39:33 PM »
What do you mean with "does not work"?

Is the folder not added?
Does IMatch throw an exception?
Have you looked at the IMatch log file after this failed for potential warnings and error messages reported?

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #19 on: July 08, 2014, 07:45:57 PM »
Here is the error message = "Subs can't be used in expressions"
The folder is not created.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #20 on: July 08, 2014, 10:49:46 PM »
This error message indicates a syntax error in your script, not an IMatch error message.
Show your full code.

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #21 on: July 09, 2014, 12:02:28 AM »
Here it is.

Code: [Select]
Option Explicit

Sub Main
Dim newFolder As IMFolder
Dim folderMonthPath As String
folderMonthPath = "E:\Photography\My Pictures\2017\201703"
Set newFolder = Database.AddFolder (folderMonthPath,True )
Debug.Print newFolder.Files.Count

End Sub

The same error shows up.

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #22 on: July 09, 2014, 03:15:57 AM »
Try something like this....

Code: [Select]
Option Explicit

Sub Main
Dim newFolder As IMFolder
Dim folderMonthPath As String
folderMonthPath = "E:\Photography\My Pictures\2017\201703"
MkDir folderMonthPath
Database.AddFolder (folderMonthPath,True )
Set newFolder = Database.Folders(folderMonthPath)
Debug.Print newFolder.Files.Count

End Sub

Note that in order for the E:\Photography\My Pictures\2017\201703 folder to be created first the folder E:\Photography\My Pictures\2017 must exist or you will get an error.


JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #23 on: July 09, 2014, 03:23:13 AM »
And if the folder E:\Photography\My Pictures\2017\201703 exists on your computer and you just want to add it to your database, comment out the line in my script that starts with MkDir

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #24 on: July 09, 2014, 07:28:58 AM »
Thanks John. It worked with a slight modification as follows.

Replace this

Code: [Select]
Set newFolder = Database.Folders(folderMonthPath)
by this

Code: [Select]
Set newFolder = Database.Folders.Item(folderMonthPath)

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #25 on: July 09, 2014, 01:33:19 PM »
Hi guys. I am trying to use the metadata to have access to IPTC and EXIF tags in an image. Using sample scripts I am trying to write a script that will read all the IPTC and/or EXIF tags of the image. However I got stuck with the following code:
Code: [Select]
Dim vals As TagValues
Dim v As TagValue
Dim td As TagData
Debug.Print f.FileName; " with "; CStr(f.TagData.Count); " tag values"
Set td = Database.GetMetadataTags( , "IPTC")
Error message is:
Code: [Select]
10094 ActiveX Automation Object var is 'Nothing'

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #26 on: July 09, 2014, 06:27:39 PM »
Database.GetMetadataTags you'll see that it returns an Variant array of strings, containing the names of all tags which match your pattern. You cannot use assign the result to a TagData instance. The GetMetadataTags just lists the names of all tags IMatch knows.

Code: [Select]
Dim tags As Variant
Dim t As String
tags = Database.GetMetadataTags(,"IPTC")

For Each t In tags
Debug.Print t
Next

Please see the IMatch help for the GetMetadataTags for more examples on how to use this method.

Please study the Metadata sample script to see how to read and write tag data for files.




phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #27 on: July 10, 2014, 01:01:25 PM »
Hi Gentlemen,
Upon Mario's suggestions

Quote
Please study the Metadata sample script to see how to read and write tag data for files.

I have studied the Metadata sample scripts. There is however still a question in my mind and unless this is clarified a lot of time will probably be wasted and it brings me to the edge of  abandoning the product. The logical relationship between tag, tags, tagdata, tagvalue, tagvalues, taginfo and the rest.
1.    Now a file has tagdata attached to it. Which gives access to tagdata.values and tagdata.taginfo. This is a hierarchical relationship as file>TagData>Values>Info
2.    A database has tags. It is possible to list the tags that a database may contain.
3.    What is the relationship between the TagData that a file has attached to it and the Tags that the data base contains. How does the record structure look like. Is it a long string of characters attached to each file
Tag + Tagdata Values Info Group Id + Tagdata Values Info Key + Tagdata Values Info Id + Tagdata Values Info Name + Tagdata Values Info Name Id + Tagdata Values Info Group Name + Tagdata Values Info Group Id. If that is the case then if I scan the character string from left to right I can easily locate the elements I want and get them. In that case what is the name of the string for a file . If this is not the case what is the structure..?

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #28 on: July 10, 2014, 02:11:20 PM »
GetMetaDataTags returns a list of all tags known to ExifTool/IMatch.

The metadata for a file is returned as a TagData instance.
TagData has one or more TagValues for each tag for which the file has data. For example, it will have 10 TagValues for the tag Keywords when the file has 10 keywords). The TagInfo class delivers information about a tag. e.g. name, description, data type when available.

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #29 on: July 10, 2014, 03:04:56 PM »
If it's of any help to you, here is a demo script that uses TagData, TagValue, and TagValues to extract Hierarchical Keywords from the selected file and debug prints them one at a time.

Select an image and use F8 to run the script one line at a time.

Code: [Select]
'#Language "WWB-COM"
Option Explicit

Sub Main
Debug.Clear

Dim f As File
Set f = Application.GetFileWindow(imfwtCurrent).FocusedFile
If f Is Nothing Then
MsgBox "A file must be selected!"
Set f = Nothing
Exit Sub
End If

Dim data As TagData
Dim vals As TagValues
Dim v As TagValue

Set data = f.TagData ' Get all metadata from the selected image
Set vals = data("XMP::Lightroom\hierarchicalSubject\HierarchicalSubject\0") ' Get all the keywords from the metadata

For Each v In vals
Debug.Print v ' Debug print each keyword one at a time.
Next
Set f = Nothing
Set data = Nothing
Set vals = Nothing

End Sub

DavidOfMA

  • Sr. Member
  • **
  • Posts: 253
  • Writer/Photographer/Therapist
Re: File organization script migration from imatch 3 to 5
« Reply #30 on: July 10, 2014, 03:28:36 PM »
Hi, John. It's pretty clear that you've spent a lot of time figuring out how to do, in IMatch 5, what you could do in IMatch 3 (and how to do more). I wonder if you could be persuaded to create a short guide for the rest of us of "equivalents," essentially a gathering-together of the tips and examples you are providing in threads like this one. The problem with learning from an exhaustive help file or reference manual is that you have to know what you are looking for, or to study the whole thing, before you can do much useful work. I remember one of the scripters on the IMatch 3 forum did something similar (wrote a tutorial on scripting) and after I worked my way through it, the whole process became 80% quicker and easier.

Just a suggestion. In any case, thanks for your frequent clarifications and examples. Much appreciated.

David

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #31 on: July 10, 2014, 04:29:56 PM »
Hi David,

I'd be happy to write a migration guide if I had the time and expertise but time is usually pretty short for me not to mention my expertise.  ;)

It works better for me to do it as I have been, to answer specific script questions when I can as users have them.

Erik

  • Sr. Member
  • **
  • Posts: 286
Re: File organization script migration from imatch 3 to 5
« Reply #32 on: July 10, 2014, 05:35:03 PM »
John,

I actually like what you've been doing here.  It might be nice for a moderator to put some of these posts in a sticky up a level or under a different forum than the Migration one.    It would help serve the purpose of the previous request as it fills out. 

As complicated as scripting is, I do have to say that I find it easier in IM5 than it was in IM3.  Some of it maybe related to the fact I am scripting for my job a lot, which is carrying over into working with IM (My job is engineering and seismology using Python for scripting, so it isn't very related).  I find the object model more intuitive to use than before.  It just gets difficult figuring out exactly what you need sometimes (for instance there is a lot of Tag related methods), but that is to be expected.

- Erik

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #33 on: July 10, 2014, 08:02:52 PM »
Erik I agree with you about version 5 scripting being easier than version 3.  I came to the same conclusion 2 or 3 years ago when I was rewriting all my scripts during the beta period.

I've also wondered about having a script demo section here on the forum, but what's stopped me so far from creating one is the fact that Mario has already written many sample scripts that come with version 5.

DavidOfMA

  • Sr. Member
  • **
  • Posts: 253
  • Writer/Photographer/Therapist
Re: File organization script migration from imatch 3 to 5
« Reply #34 on: July 10, 2014, 08:23:28 PM »
I think a script demo section would be helpful. It allows for discussion around the scripting basics that, for people like me who script only when necessary, would provide help beyond looking through the Help and sample scripts.

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #35 on: July 10, 2014, 09:31:35 PM »
I have no problem contributing to a demo scripts forum but lets see what Mario has to say about it.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #36 on: July 10, 2014, 09:33:29 PM »
Be my guest. The Scripting and Apps panel was created for exactly this purpose.

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #37 on: July 10, 2014, 09:35:58 PM »
Well that didn't take long. lol  ;D

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #38 on: July 11, 2014, 07:58:19 AM »
Hi Gentlemen,
I completely agree with DavidOfMA in the statement
 
Quote
The problem with learning from an exhaustive help file or reference manual is that you have to know what you are looking for, or to study the whole thing, before you can do much useful work.
.
Probably as Mario points out there is a lot of exhaustive documentation where all these can be found or deducted. However most of the time you do not need the whole thing but just a small portion of it and you do not know where to look for it. A special section would be really helpful. In the meantime I have written a small script for image selection. Where you just choose either the active selection or the active folder or the 2 levels of subfolders under the active folder just by clicking on the appropriate boxes where you see the number of images. I am posting it here thinking that it might be useful as a front end for many systems.
Code: [Select]
'#Language "WWB-COM"

Option Explicit
Sub Main
'===============================================================================================
'   file selection macro
'===============================================================================================

Dim imgs As IFiles
Dim simgs As IFiles
Dim img As IFile
Dim simg As IFile
Dim childFolders As IMFolders
Dim childFolder As IMFolder
Dim grandChildFolders As IMFolders
Dim grandChildFolder As IMFolder
Dim Push As Integer
Dim countchildren As Double
Dim TotalfileCount As Double
Dim TotalSubFolderCounter As Double

countchildren = 0
TotalfileCount = 0
'=======================================================================================
' Determine the total number of files in all subfolders to be processed
'=======================================================================================
Set childFolders = Application.ActiveFolder.Children
TotalSubFolderCounter = childFolders.Count
Debug.Print "TotalSubFolderCounter= ";TotalSubFolderCounter

Set simgs = Application.GetFileWindow(imfwtCurrent).SelectedFiles
For Each childFolder In childFolders
simgs.CombineFiles (childFolder.Files )
countchildren = childFolder.Files.Count + countchildren
Set grandChildFolders = childFolder.Children
For Each grandChildFolder In grandChildFolders
simgs.CombineFiles (grandChildFolder.Files)
countchildren = grandChildFolder.Files.Count + countchildren
Next grandChildFolder
Next childFolder

Debug.Print "countchildren = ";countchildren
Debug.Print "simgs.Count- ";simgs.Count

Begin Dialog UserDialog 500,300,"Organize Folders With IPTC"
PushButton 50,20,400,40,"Use Active Folder  =  "&CStr(ActiveFolder.Files.Count)&"  file(s)",.Push1
PushButton 50,80,400,40,"Use Current Selection  =  "&CStr(Application.GetFileWindow(imfwtCurrent).SelectedFiles.Count)&"  file(s)",.Push2
PushButton 50,140,400,40,"Include childfolders  =  "&CStr(countchildren)&"  file(s)",.Push3
' PushButton 50,200,400,40,"Use bookmarks  =  "&CStr(Database.Collections.Get(ctypeBookmark).Files.Count)&"  file(s)",.Push4
PushButton 210,210,80,45,"Exit",.Push5
Text       220,270,190,20,"©2014 CB"
End Dialog
Dim dlg As UserDialog
Push=Dialog(dlg)
Select Case Push
Case 1
Set imgs = ActiveFolder.Files
TotalfileCount = imgs.Count
Case 2
Set imgs = Application.GetFileWindow(imfwtCurrent).SelectedFiles
TotalfileCount = imgs.Count
Case 3
Set imgs = simgs
TotalfileCount = simgs.Count
Case 4
Exit All
End Select
MsgBox "TotalfileCount= " & TotalfileCount
End Sub

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #39 on: July 11, 2014, 08:20:29 AM »
Hi John,
The script you posted works fine.
Code: [Select]
Set vals = data("XMP::Lightroom\hierarchicalSubject\HierarchicalSubject\0") ' Get all the keywords from the metadataCould you tell me what characters to use instead of
Code: [Select]
XMP::Lightroom\hierarchicalSubject\HierarchicalSubject\0to get the values of the tags iptcDate, iptcCaption, iptcObject, iptcKeywords, iptcByline, iptcCountry, iptcCity,  iptcEditStatus,  iptcOrigDate and exifOrigDate.
Many thanks.

Richard

  • Guest
Re: File organization script migration from imatch 3 to 5
« Reply #40 on: July 11, 2014, 03:00:19 PM »
I don't agree with
"The problem with learning from an exhaustive help file or reference manual is that you have to know what you are looking for, or to study the whole thing, before you can do much useful work."
when it comes to IMatch. F1 gets me to the part of Help that I need so I do not need to study the whole help file.



JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: File organization script migration from imatch 3 to 5
« Reply #41 on: July 11, 2014, 03:04:53 PM »
Could you tell me what characters to use instead of
Code: [Select]
XMP::Lightroom\hierarchicalSubject\HierarchicalSubject\0to get the values of the tags iptcDate, iptcCaption, iptcObject, iptcKeywords, iptcByline, iptcCountry, iptcCity,  iptcEditStatus,  iptcOrigDate and exifOrigDate.
Many thanks.

When you import your images IMatch/ExifTool copies the obsolete IPTC metadata from those images into xmp fields which you then work with.  After that IMatch and ExifTool work behind the scenes to keep the metadata synchronized across all the relevant metadata fields.  In other words you don't work with IPTC now, IMatch and ExifTool does that for you when you edit the appropriate xmp metadata field.

For example the old IPTC caption is now the {File.MD.XMP::dc\description\Description\0} tag.
IPTC keywords is the {File.MD.XMP::Lightroom\hierarchicalSubject\HierarchicalSubject\0} tag I used up above.

Use the metadata panel to find the tags to extract/display or modify the metadata you need to use.

Hopefully if I didn't say all this quite right Mario will correct me.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #42 on: July 11, 2014, 03:15:05 PM »
The Copy as Variable command available in the Metadata Panel is very helpful for this kind of thing.
As is the Var Toy App.
IMatch supports over 10,000 metadata tags. As Carl said, you should not update legacy data your self (or at all for new files). The IPTC namespaces in XMP (and their corresponding tags and variables) is what you want to use.

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #43 on: July 11, 2014, 04:11:21 PM »
OK Mario I see what you mean. Now I am trying to use metadata templates to put in  a certain number of tags and their values.  As far as I can see I can input in batches which is quite handy. To try I have devised a template with 7 tags and inserted values for them. Now the template is ready for 156 images. Looking at the help file I see that it is only necessary to select these images and then call tools>Metadata templates>temp_name. But then nothing happens. Staying in the same selection I refresh the screen nothing happens. How shall I apply this template to the selected images.

Mario

  • IMatch Developer
  • Administrator
  • *****
  • Posts: 29382
Re: File organization script migration from imatch 3 to 5
« Reply #44 on: July 11, 2014, 05:33:32 PM »
When you run a Metadata Template it works on all selected files.

Quote
But then nothing happens.

This means what, exactly?

How does your Metadata Template look like?

Does the Template not run?
No metadata updated?
Only some metadata updated?
How do you check if metadata is updated?
Running a template for about a hundred files takes maybe one or two seconds...

Please switch IMatch to debug logging and retry your experiment.
Then attach attach the log file.

See How to report bugs for details.



Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: File organization script migration from imatch 3 to 5
« Reply #45 on: July 11, 2014, 07:16:33 PM »
I don't agree with
"The problem with learning from an exhaustive help file or reference manual is that you have to know what you are looking for, or to study the whole thing, before you can do much useful work."
when it comes to IMatch. F1 gets me to the part of Help that I need so I do not need to study the whole help file.

I have some sympathy for the quoted view, at least for scripting.  But I don't think that the answer is to give up and ask for basic help on the forum.  I have found the sample scripts and those of other users to be of the most benefit, and if there's something in there I don't understand then I look at the help, and if I still don't understand then I ask here.  We all have to ask questions sometimes, but a bit of self-help should be exercised first.

It is a shame that khodadad isn't around to migrate his scripting guide to V5.

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #46 on: July 11, 2014, 10:07:47 PM »
Some contribution to this discussion. It is good to have lots of detailed documentation in the form of help files. It is also nice to have a software product which has limitless possibilities and can do everything that a photo professional can ask for. On the other hand forums are places to ask questions and get help. We try to help each other as much as possible. No user is getting paid for helping the others in the forum. You may not know the answer or may not want to answer the question, but that is no reason to say read the documentation it is out there find it yourself. We know it is out there some place, but we do not know exactly where and it would not hurt anyone to post the question and ask for help instead of spending hours looking for an answer. Especially if it is about the operation of a product as complicated as and as powerful as this one where most of the time the relevant information is hidden somewhere in a panel or a function among hundreds of others. Lets try to be a bit more tolerant about these questions. Nobody is saying that it is a bad product. This is just a race we all have to run against time. We all try to accomplish more in less time and that is why we ask questions.

Richard

  • Guest
Re: File organization script migration from imatch 3 to 5
« Reply #47 on: July 12, 2014, 12:50:29 AM »
Quote
On the other hand forums are places to ask questions and get help.

Of course forums are a place to get answers but so are the help files. After years of reading posts from IMatch users I know that the kind and helpful members do get tired of too many questions from a person when it is obvious that person did not look for an answer in the help files. Conversely they will bend over backwards to help a person who has obviously tried to find answers but failed. I have seen the same question answered time and again but in different ways until the person asking finally reads an answer worded in a way he or she can understand.

phbee2014

  • New Members
  • *
  • Posts: 19
Re: File organization script migration from imatch 3 to 5
« Reply #48 on: July 12, 2014, 07:56:41 AM »
Well as I said we are racing against time and nobody has much time to discuss who said what, instead the time and energy should be spent in answering questions and helping. Nevertheless the post requires some comment.

Firstly, you say
Quote
... that the kind and helpful members do get tired of too many questions...

As I said you are not obliged to answer. If you do not want to answer you just ignore the question.

Secondly,  you say
Quote
...when it is obvious that person did not look for an answer in the help files.

How and where do you know that he did not look at the help files? In other words are you in a position to question that?

Thirdly, you say
Quote
I have seen the same question answered time and again but in different ways until the person asking finally reads an answer worded in a way he or she can understand.

I agree. Until the answer is given in a clear and understandable way. Not everyone is working full time everyday on IMatch. Short responses where just a reference is given to an obscure item sitting in a panel which you do not even know how to access do provoke further questions.


Richard

  • Guest
Re: File organization script migration from imatch 3 to 5
« Reply #49 on: July 12, 2014, 03:54:38 PM »
Quote
How and where do you know that he did not look at the help files?

Go back to the old forum and read every post. Then read every post to this forum. When you have done that, as I have done, you will have a fairly good understanding of how I can judge whether someone has tried to find answers in the help files. You will also be able to judge if the person has tried hard to find answers and is frustrated. IMatch 3 Help was not as good as IMatch 5 Help. Mario has put a ton of effort into making IMatch 5 help files much better. If a user does not understand a feature in IMatch 5, all they have to do is select the panel or whatever and press [F1] to be taken to the pertinent files. The means to find answers are built in but the user must RTFM.

Quote
As I said you are not obliged to answer. If you do not want to answer you just ignore the question.

Nobody is obliged to answer any post and, unless they are a moderator, they don't even have to look at a post. BUT should forum members make it a habit of not reading or answering posts? I would hope not but neither should they have to waste time with posts where the one asking could have gotten the answer quicker by RTFM then composing a post. Those who don't make an attempt to find answers in help generate chaff here on the forum. That chaff makes it harder for a person who really needs help to get help. As you read all the posts that I have read in the old forum you will see replies where the person replying has spent a lot of time, sometimes hours, to give the needed answer(s). You will also see where a person has written a script, that took days of effort, for the benefit of others. Volunteers who answer questions and write scripts for others don't get paid to do so. Do you really believe that their time should be wasted on replies to users to lazy to try to help themselves? Some members may have nothing better to do but Mario's time is extremely valuable to all users and I flat resent anyone wasting his time with questions they could have answered by Reading The Fine Manual.