Hot Folder to open New picture in Preview

Hey there,

I’d like to do the following:

Whenever a new file is put into a folder, open that file in Preview (fullscreen, if possible).

Background: I’ve got a remote control software for my camera, and when I connected it to my mac, and take a new picture, this picture is automatically put in a folder of my choice. Now what I’d like to have is that this new file is automatically opened and displayed in fullscreen, so that I have sort of a “much bigger camera screen” :wink:

Here is my attempt:

on adding folder items to this_folder after receiving these_items
	tell application "Preview"
		activate
		open these_items
	end tell
end adding folder items to

as a folder action, but this doesn’t work :frowning: Why?

[Please be easy on my, I’m still a newbie ;-)]

Thanks for your help,

Floz

Hi Floz,

the script itself seems to work, but for a folder action there are some requirements:
¢ The script must be located in /Library/Scripts/Folder Action Scripts/ or in ~/Library/Scripts/Folder Action Scripts/
¢ Folder actions must be enabled
¢ the script must be attached to the hot folder

Thx for your quick reply, Stefan…

Well, of course I did attach it to a folder and all that, but it still doesn’t work. Preview opens up, but that’s it :frowning:

Hi

Apple’s Preview app isn’t the most scriptable of apps! in fact it isn’t.

However checkout this link! to add basic applescript functionality to preview!!
its not much but it might help.

http://www.macworld.com/article/53391/2006/10/previewscript.html

That’s right. But there is a way to avoid telling Preview.app something


on adding folder items to this_folder after receiving these_items
	tell application "Finder"
		open these_items using application file (path to application "Preview")
	end tell
end adding folder items to

Thanks lads, here is my fugly solution sofar:

on adding folder items to this_folder after receiving these_items
	-- close preview
	tell application "Preview" to quit
	-- give it some time
	delay 0.5
	-- open new in preview
	tell application "Finder"
		open these_items using application file (path to application "Preview")
	end tell
	-- now go fullscreen using keyboard shortcut
	tell application "System Events"
		tell application process "Preview"
			keystroke "f" using {command down, shift down}
		end tell
	end tell
end adding folder items to

The first bit is to get rid of a previously opened instance of Preview… haven’t managed to smoothely exit fullscreen, close the current file, and then open the new. But brutally closing it does the trick :wink: