I have an automated workflow which downloads zip files from FTP, unzips them, archives them, sorts them, and is supposed to open any Freehand files - suppressing any dialogs - and save them out as EPS files. My problem is that I can’t seem to get the dialogs to suppress. Any takers? BTW - this is a script which runs inside a workflow automation package called Power Switch, so that is the reason for any strange looking code. When a Dialog pops up Power Switch shows Freehand receiving a type 3 error. Could we possibly build in an error handler to close that particular file and direct it to a different location?
-- ==================================================================================================
-- This is an example Applescript showing how to open a file in Freehand and save it back out as an
-- EPS file
--
-- ----------------------------------------------------------------
-- Author: David van Driessche, Gradual Software
-- Last changed: December 19, 2007
-- Copyright: (c) 2007, Gradual Software
-- ==================================================================================================
-- --------------------------------------------------------------------------------------------------
-- jobArrived
--
-- Script entry point that is called for each new job that enters the input folder for this script
-- --------------------------------------------------------------------------------------------------
on jobarrived( s, j )
-- Get the properties of the job we need to process it
tell application "Current_SWITCH_Server"
-- Get the path to the job and information about that path
set theJobPath to path of j
tell application "Finder"
set theJobInfo to (info for file theJobPath)
end tell
end tell
-- Is this is a file or a folder?
if folder of theJobInfo is true then
-- This is a job folder. Find all Freehand files in the folder and process them to
-- EPS. Send all generated EPS files along the flow using the original job (so they'll
-- all be linked to the incoming job folder.
-- Begin by creating a folder object and asking it for all its files
tell application "Finder"
set theJobFolder to folder theJobPath
set theFiles to (files of theJobFolder)
repeat with theFile in theFiles
-- get the extension of this file in upperercase
set theExtension to my changeCase( (name extension of theFile), "upper")
-- if the extension is "FH11", we're interested
if (theExtension is equal to "FH11") or (theExtension is equal to "FH") then
-- get the name of this Freehand file
set theName to name of theFile
set newName to (text 2 thru 8 of theName) & text 1 of theName
-- Create a temporary file to save the job to
tell application "Current_SWITCH_Server"
set theTempFilePath to create path j name newName & ".eps"
end tell
-- Tell Freehand to open the job and save it as EPS
tell application "FreeHand MX"
open theFile Dialogs (false)
save document 1 in file theTempFilePath as MacEPS with IncludeHFDocInEPS
close document 1 saving no
end tell
-- Done processing, send the resulting file to our single output connection
tell application "Current_SWITCH_Server"
send to single j path theTempFilePath
end tell
end if
end repeat
end tell
else
-- This is a single Freehand file. Simply ask Freehand to convert it to EPS on a
-- temporary location and then send the resulting EPS file along
-- Create a temporary file to save the job to
tell application "Current_SWITCH_Server"
-- A temporary path to save the job to
set theTempFilePath to create path j extension ".eps"
end tell
-- Tell Freehand to open the job and save it as EPS
tell application "FreeHand MX"
-- activate
open alias theJobPath Dialogs false
save document 1 in file theTempFilePath as MacEPS with IncludeHFDocInEPS
close document 1 saving no
end tell
-- Done processing, send the resulting file to our single output connection
tell application "Current_SWITCH_Server"
send to single j path theTempFilePath
end tell
end if
end jobarrived
on changeCase( this_text, this_case )
if this_case is "lower" then
set the comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set the source_string to "abcdefghijklmnopqrstuvwxyz"
else
set the comparison_string to "abcdefghijklmnopqrstuvwxyz"
set the source_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
end if
set the new_text to ""
repeat with thisChar in this_text
set x to the offset of thisChar in the comparison_string
if x is not 0 then
set the new_text to (the new_text & character x of the source_string) as string
else
set the new_text to (the new_text & thisChar) as string
end if
end repeat
return the new_text
end change_case_of
Thanks,
Lunarlandr