Get Label Index is unreliable

Hi,

I have a script that does a search on our server for Illustrator and EPS files, sorts the results for files that have been modified in the past 24 hours, and then checks the Label Index (colour label) of the Parent folder. If it is Grey (index 7), then the job is still being worked on, or has not been approved, and I want the script to ignore these items.

repeat with i in itemstomovelist
			tell application "Finder"
				set WIPCheck to (label index of i)
				delay 3
				if WIPCheck ≠ 7 then
--do stuff
end if

When I make the above call to the Finder for a server-based file, there is a delay, and I have been getting strange label indexes (indices?) come up, like -28001. It seems completely random, because I’ll run the script 10 more times, and it may be fine - so it’s really tricky to troubleshoot and discover what’s going on and the likely codes that could come up. I put in the delay in the script above, but that doesn’t seem to help.

Any ideas/suggestions would be most welcome, as I am running out of hair to pull out :rolleyes:

Thanks
Ian

Model: G5 2x2.7ghz
AppleScript: 1.10.7
Browser: Safari 523.12.2
Operating System: Mac OS X (10.4)

I had actually run into the same thing a while back. If memory serves me correctly, I was never able to figure out what the problem was, so I looked for an alternative method. :frowning:

Hi

I had a script which did something very similar but on a smaller scale which worked fine!!
are you sure when the script is being run that some of the folders or files aren’t being copied to or from the server.
hence the inconsistency.
if you can post the full script. no promises though!!

cheers

Hi, thanks for the replies

After some further testing, it only seemed to happen to certain folders. Looking at the “Properties of” of the offending folder was showing the Label Index to be <>:0, as opposed to showing as label index:0 on other folders. I don’t know if the call to get label index couldn’t find the property (even though the class is the same thing) and so defaults to an error code.

Either way, I came up with a solution. When I get into work tomorrow, i’ll post what I came up with.

Thanks

Ian

Hi again,

I have been using the following with no occurrences of the previous errors.


set itemstomovelist to choose folder with multiple selections allowed
set listofnumbers to {}
set err_log to {}
if itemstomovelist is not equal to {} then
	set lst to {0, 1, 2, 3, 4, 5, 6, 7}
	repeat with i in itemstomovelist
		tell application "Finder"
			get properties of i
			set WIPCheck to (label index of the result)
			if WIPCheck is not in lst then
				set WIPCheck to false
			end if
			if WIPCheck is not false then
				set end of listofnumbers to WIPCheck
				if WIPCheck = 0 then
					-- do stuff
				end if
			else
				set end of err_log to ("Error - " & ((i as string) & "- Could not get Label Index/"))
			end if
		end tell
	end repeat
end if
return listofnumbers

It seems that

get properties of i
			set WIPCheck to (label index of the result)

was more successful than a straight

set WIPCheck to (label index of i)

I also added the check whether the number was in the 0-7 list. I’ll have to monitor it to see how successful this is.

Thanks

Ian

can you extract the index number from <>:0