OmniGraffle to Word X best way?
Joel Page
ironfist at mac.com
Thu Jan 22 20:15:46 PST 2004
Oops, no attachments to the list. Here's the script:
-----
property done_foldername : "Previewable EPS Files"
property originals_foldername : "Plain EPS Files"
property newimage_extension : "eps"
-- the list of file types which will be processed
-- eg: {"PICT", "JPEG", "TIFF", "GIFf"}
property type_list : {"EPSF"}
-- since file types are optional in Mac OS X,
-- check the name extension if there is no file type
-- NOTE: do not use periods (.) with the items in the name extensions
list
-- eg: {"txt", "text", "jpg", "jpeg"}, NOT: {".txt", ".text", ".jpg",
".jpeg"}
property extension_list : {"eps", "ps"}
on adding folder items to this_folder after receiving these_items
tell application "Finder"
if not (exists folder done_foldername of this_folder) then
make new folder at this_folder with properties {name:done_foldername}
end if
set the results_folder to (folder done_foldername of this_folder) as
alias
if not (exists folder originals_foldername of this_folder) then
make new folder at this_folder with properties
{name:originals_foldername}
set current view of container window of this_folder to list view
end if
set the originals_folder to folder originals_foldername of this_folder
end tell
try
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
set the item_info to the info for this_item
if (alias of the item_info is false and the file type of the
item_info is in the type_list) or (the name extension of the item_info
is in the extension_list) then
tell application "Finder"
my resolve_conflicts(this_item, originals_folder, "")
set the new_name to my resolve_conflicts(this_item,
results_folder, newimage_extension)
set the source_file to (move this_item to the originals_folder
with replacing) as alias
end tell
process_item(source_file, new_name, results_folder)
end if
end repeat
on error error_message number error_number
if the error_number is not -128 then
tell application "Finder"
activate
display dialog error_message buttons {"Cancel"} default button 1
giving up after 120
end tell
end if
end try
end adding folder items to
on resolve_conflicts(this_item, target_folder, new_extension)
tell application "Finder"
set the file_name to the name of this_item
set file_extension to the name extension of this_item
if the file_extension is "" then
set the trimmed_name to the file_name
else
set the trimmed_name to text 1 thru -((length of file_extension) +
2) of the file_name
end if
if the new_extension is "" then
set target_name to file_name
set target_extension to file_extension
else
set target_extension to new_extension
set target_name to (the trimmed_name & "." & target_extension) as
string
end if
if (exists document file target_name of target_folder) then
set the name_increment to 1
repeat
set the new_name to (the trimmed_name & "." & (name_increment as
string) & "." & target_extension) as string
if not (exists document file new_name of the target_folder) then
-- rename to conflicting file
set the name of document file target_name of the target_folder to
the new_name
exit repeat
else
set the name_increment to the name_increment + 1
end if
end repeat
end if
end tell
return the target_name
end resolve_conflicts
-- this sub-routine processes files
on process_item(source_file, new_name, results_folder)
-- NOTE that the variable this_item is a file reference in alias format
-- FILE PROCESSING STATEMENTS GO HERE
try
set the source_item to the quoted form of the POSIX path of the
source_file
-- the target path is the destination folder and the new file name
set the target_path to the quoted form of the POSIX path of
(((results_folder as string) & new_name) as string)
with timeout of 900 seconds
do shell script ("/usr/local/bin/epstool --copy " & source_item & "
" & target_path)
do shell script ("/usr/local/bin/epstool --gs /usr/local/bin/gs
--add-pict-preview --mac-rsrc " & source_item & " " & target_path &
"/..namedfork/rsrc")
end timeout
on error error_message
tell application "Finder"
activate
display dialog error_message buttons {"Cancel"} default button 1
giving up after 120
end tell
end try
end process_item
-----
Or download it here:
http://homepage.mac.com/ironfist/other/EPSPreview.scpt.zip
Joel
On Jan 22, 2004, at 8:01 PM, Joel Page wrote:
> If it did, I have it here, and the good news that the recipe (involved
> as it may be) does indeed work.
>
> A summary of Adam's steps:
>
> 1. Install GhostScript (http://www.ghostscript.com/). As mentioned
> before, Fink has a package, I myself used the i-Installer available at
> rna.nl (http://www.rna.nl/ii.html) with zero difficulty.
>
> 2. Install Epstool (http://www.cs.wisc.edu/~ghost/gsview/epstool.htm)
> as well, download the Unix tarball
> (ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/ghostgum/epstool
> -3.04.tar.gz), toss out the binary and via the Terminal navigate to
> the folder that gets downloaded and type "make epstool" to create the
> new binary.
>
> 3. The AppleScript attached will want epstool in /usr/local/bin/ so
> you must be an admin to place it there (it might work elsewhere, I
> haven't tested in other locations).
>
> 4. Take the attached script and put it in /Library/Scripts/Folder
> Action Scripts/ (again, admin access is needed).
>
> 5. Make a folder to be the target for your EPS exports (local disks
> only, it failed on a mounted NFS network home folder), and via the
> contextual menu attach the script to the folder.
>
> 6. Export EPS files there, stand and be amazed.
>
> Massive kudos out to Adam, on a side note we've asked the fine folks
> who make i-Installer to add Epstool to their list of packages and I've
> asked the add-ons team to see if they can't make the process easier as
> well.
>
> Joel
>
>
>
>
> On Jan 20, 2004, at 2:33 AM, Andrew Shugg wrote:
>
>> On 19/01/2004, at 11:00 PM, Adam Maxwell wrote:
>>> BTW, did my AppleScript for adding the preview as a Folder Action
>>> make it to the list? I cc'd to the list, but the message might have
>>> been too large, since I didn't see it. If anyone wants this, e-mail
>>> me (it uses ghostscript and epstool to add a TIFF or PICT preview to
>>> an EPS file when saved to a watched folder).
>>
>> Nope, must've been eaten by the listserv. *listens for lip-smacking
>> noises*
>>
>> There was a message from you a few days ago with the command-line
>> instructions for running epstool to do the job, and another saying
>> that it might be possible to wrap this in an AppleScript, but nothing
>> after that ...
>>
>> It might be a nice addition to the user-contributed section on the
>> OmniGraffle support page.
>>
>> Andrew S.
>>
>> --
>> Andrew Shugg <ashugg at mac.com>
>> ObDotMacHome <http://homepage.mac.com/ashugg/>
>>
>> "Time is an illusion. Lunch-time, doubly so." -- Ford Prefect.
>>
>> _______________________________________________
>> OmniGraffle-Users mailing list
>> OmniGraffle-Users at omnigroup.com
>> http://www.omnigroup.com/mailman/listinfo/omnigraffle-users
> _______________________________________________
> OmniGraffle-Users mailing list
> OmniGraffle-Users at omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/omnigraffle-users
More information about the OmniGraffle-Users
mailing list