Author Topic: Strange Error when trying to apply label to a file (Worked in IM3)  (Read 3147 times)

ubacher

  • Oldtimer
  • ****
  • Posts: 2297
Please see screen shot - complete program with error message.

Had no problem with this in IM3.

[attachment deleted by admin]

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: Strange Error when trying to apply label to a file (Worked in IM3)
« Reply #1 on: October 14, 2013, 09:28:11 PM »
I believe this is by design for IMatch 5. 

If you check the help page for collections it will mention that only mutable collections can be modified by a script and labels are not mutable. 

Why I don't know but I think that's the reason you get an error.

thrinn

  • Hero Member
  • ***
  • Posts: 999
Re: Strange Error when trying to apply label to a file (Worked in IM3)
« Reply #2 on: October 14, 2013, 09:47:17 PM »
I guess the reason is that Label collections are generated from XMP label metadata. So changing the corresponding metadata tag of a file will automatically "assign" the file to the Label collection, but not the other way round.
I must confess that I did not try it, but it seems logical to me.
Thorsten
Win 10 / 64, IMatch 2018, IMA

ubacher

  • Oldtimer
  • ****
  • Posts: 2297
Re: Strange Error when trying to apply label to a file (Worked in IM3)
« Reply #3 on: October 15, 2013, 08:04:53 AM »
How do I set the red label in a script then? Should be a legitimate operation - no?
Code snippet appreciated - or some script where it is done.

Ferdinand

  • 100 years since I was shot and a war was started
  • Global Moderator
  • *****
  • Posts: 1670
Re: Strange Error when trying to apply label to a file (Worked in IM3)
« Reply #4 on: October 15, 2013, 02:41:20 PM »
You set the label directly, without using collections.  There are special methods for setting ratings and labels which avoid some of the more complex code normally required when writing metadata in a script.  This is similar to how it was done in V3.6

Code: [Select]
img.Label = "xxx"
img.Rating = "y"

These are documented in the help file under the methods for "File".

Of course there are also more complex ways to do this, but this is the simplest.

ubacher

  • Oldtimer
  • ****
  • Posts: 2297
Re: Strange Error when trying to apply label to a file (Worked in IM3)
« Reply #5 on: October 15, 2013, 06:11:55 PM »
Thank you. My coding efforts consist mostly of copying/modifying existing code.

JohnZeman

  • Global Moderator
  • *****
  • Posts: 1442
  • I'm too damn old to act my age.
Re: Strange Error when trying to apply label to a file (Worked in IM3)
« Reply #6 on: October 16, 2013, 12:32:25 AM »
You also may want to look at the Ratings & Label sample script in the System > Samples section.

Lots of good info in that section.