Posix file problems in Mavericks

What is going on here?

tell application “Finder” to get POSIX file “/Users/j/Pictures”
– This works

set xxx to “/Users/j/Pictures”
tell application “Finder” to get POSIX file xxx
– Finder got an error: Can’t get POSIX file “/Users/j/Pictures”.

I’m not sure why that’s happening, but FWIW, POSIX file belongs to Standard Additions, so you should try to avoid using it in application tell blocks either way.

Hi Shane,

It was really a part of a move command, hence the FInder block.

set xxx to "/Users/j/Pictures"
POSIX file xxx

… works as expected.

Right, but I’m suggesting it shouldn’t be – that it should be kept outside application tell blocks.

If you really need to trigger POSIX file in a tell Finder block, look at this short script:


tell application "Finder"
	# Wrong code
	get POSIX file "/Users/yvankoenig/Pictures"
	-- This works
	log result
	-->(*file Aluice_250:Users:yvankoenig:Pictures*)
	# Correct code
	tell me to get POSIX file "/Users/yvankoenig/Pictures"
	log result
	-->(*file Aluice_250:Users:yvankoenig:Pictures*)
	# Correct code
	set xxx to "/Users/yvankoenig/Pictures"
	tell me to get POSIX file xxx
	log result
	-->(*file Aluice_250:Users:yvankoenig:Pictures*)
end tell

Yvan KOENIG (VALLAURIS, France) samedi 18 janvier 2014 12:23:20