convert string to file (name)

Hi,

I think I have a releatively easy question but I just can’t get it to work.

I have a set of images. In the routine I’m using I deliver the filenames as strings like /Users/UserName/Pictures/img01.jpg (so no quotes)
somewhere in my routine (it’s a loop) I have


--set counter to 1
repeat with anItem in theItems
  --display dialog "number " & counter & " " & anItem
  set imageFile to (open anItem)
  .. do the rest ..
 --set counter to counter + 1
end repeat

This doesn’t work.
I already tried:
set imageFile to (open anItem) as alias
set imageFile to (open Posix path of anItem)
set imageFile to (quoted form of Posix path of anItem)

and a couple of other (ridiculous) options but I can’t get it to work.

I also did a “display dialog” as first line in the repeat statement (and disabling the rest) to see whether my string was correct. It was exactly as I expected it to be.

What is it I’m overlooking?

I’m guessing you want to open those files ?
Then this will do the trick,

set counter to 1
repeat with anItem in theItems
	display dialog "number " & counter & " " & anItem
	tell application "Finder"
		open (POSIX file anItem as alias)
	end tell
	set counter to counter + 1
end repeat

But it just opens, AppleScript doesn’t read the info.

Thanks for your reply, but I don’t want Finder to act on it. I want Image Events to work on it.

Actually I do a:

tell application “Image Events”
launch
… repeat loop
end tell

It’s just that Image Events mentions that it can’t find. In the same time the error message shows the correct path+file.

I’ve never used Image Events… -I don’t even know what it is for? Image editing ?
Maybe others can help.

Well,

It’s solved.

I used, among others,

set imageFile to (open anItem) as alias

This is not correct. After looking into some other applescripts I changed it to:

set imageFile to (anItem as alias)
set imageFile to (open imageFile)

Now it works (sigh)