Merlin Applescript samples

Setting a common information

Have you ever wanted to set a common information to your resources and wondered how to do so at once? Here is a small Applescript going through all project resources and toggling their ‘is private’ flag, but of course you can modify the sample to set another resource property if you need so…

set userCanceled to false
set dialogResult to display dialog "Shall I toggle the private flag of all resources?" ¬
        buttons {"Cancel", "OK"} ¬
	default button "OK" cancel button "Cancel"
if userCanceled then
	-- do nothing
else
	tell application "Merlin"

		activate
		tell first document
			set TheRes to resources
			repeat with n in TheRes
				tell n
					if is private is true then
						set is private to false
					else
						set is private to true
					end if
				end tell
			end repeat
		end tell
	end tell
end if

Exporting via Applescript

Here another sample exporting the resources calendar one by another in the ics format for iCal.

property pos : "/export" -- path for the export files, it has to exist on your hard disk
set userCanceled to false
set dialogResult to display dialog ¬
	"Shall I export all resource calendars in " & pos & "?" buttons {"Cancel", "OK"} ¬
	default button "OK" cancel button "Cancel"
if userCanceled then
	-- do nothing
else
	tell application "Merlin"
		activate
		set doc to front document
		tell first document
			set TheRes to resources
			repeat with n in TheRes
				tell n
					set TheName to title of n
					export doc as iCal file to path (pos & "/merlin(" ¬
                                       & TheName & ").ics") with resource n
				end tell
			end repeat
		end tell
	end tell
end if

3 thoughts on “Merlin Applescript samples

  1. I’m trying to make the export iCal script to work and having problem.

    I’ve created a merlin(name).ics and add it to iCal.
    When I run the script it says the file merlin(name).ics doesn’t exist.

    I tried to put it in an export folder but not working either ??

    Does anyone had it worked successfully ???

  2. Of course it works 🙂 we had tested this script before posting, but I have tested it once again to make sure just in case…

    Does your script is trying to import the exported ics file in iCal automatically?

    How are you doing this?

    Regards, Vicky

  3. so here is what to do, if you want to re-import the just exported files into iCal

    set Thefile to (pos & “/merlin_” & TheName & “.ics”)
    tell application “Finder”
    open POSIX file Thefile of me
    delay 5
    end tell

    Note: you need a small delay… otherwise the import in iCal would happen much too quickly and you won’t have any time to react on the question, whether to import on the existing calendar or create a new calendar.

Comments are closed.