Re: Info for issues: Converting EPS to AI script
Re: Info for issues: Converting EPS to AI script
- Subject: Re: Info for issues: Converting EPS to AI script
- From: kai <email@hidden>
- Date: Mon, 29 Jan 2007 01:16:41 +0000
On 26 Jan 2007, at 17:36, Grove, Brian wrote:
Concept:
We have Folder with many subfolders for our artwork. We used to
use .eps files but now want to completely convert them to .ai for
stability. The originally I had a dropitem script that worked, but
new criteria demands that it has: user selected folders, checks to
make sure the sourceFolder is not on network, works only for
Illustrator .eps files (ART5), saves new .ai file in aiFolder,
moves or duplicates skipped files into skipFolder
Known issues:
In conVert(sourceFolder), I am have trouble with the getting past a
"set this_item to (item i of sourceFolder)" and "set item_info to
the info for this_item."
Because of this, I have not been able to continue on to check my
sub-routines.
I have read that OSX handles "info for" differently that OS9 and
have tried the fixes I have found to no avail.
I have included my full script for reference and in case it can be
hacked for other uses. I am guessing that I have missed some basic
concept, but can't figure it out.
As already mentioned, Brian, the principal issue here was a repeat
loop iterating through the characters of the string represented by
the variable 'sourceFolder' (rather than processing the items within
the folder itself).
Having just had a chance to take a quick look at this, I wonder if
the script might be simplified somewhat by recruiting Finder to
filter out the required files, rather than individually testing with
the 'info for' command, and using the various text parsing and
concatenation routines.
Since I don't use Illustrator, I can't test the 'process_items'
handler below - so it's been largely left as it appears in your
original script. Hopefully, the rest of the code might give you an
idea or two.
------------------
property type_list : {"EPSF"}
property extension_list : {"eps"}
property aiFolder : missing value
property skipFolder : missing value
to process_items from processList (* untested *)
tell application "Adobe Illustrator 10.0.3"
launch
repeat with this_item in processList
try
if file this_item is type("ART5") then
open this_item
save document 1 as Illustrator with options ¬
{compatibility:Illustrator 10, compressed:true, ¬
embed all fonts:true, PDF compatible:true} in aiFolder
close document 1 saving no
else
move this_item to skipFolder
end if
on error msg
display dialog msg
end try
end repeat
end tell
end process_items
to convert_files()
tell application "Finder"
activate
repeat
set sourceFolder to choose folder with prompt ¬
"Choose a source folder on a local volume to convert:"
if sourceFolder's disk is local volume then exit repeat
display dialog "The source folder should be located on a local
volume." buttons ¬
{"Cancel", "Try again"} default button 2 with icon 2
end repeat
set aiFolder to choose folder with prompt "Choose a destination
folder for processed AI files:"
set skipFolder to choose folder with prompt "Choose a destination
folder for skipped files:"
set processList to a reference to (document files of folder
sourceFolder's entire contents ¬
whose file type is in type_list or name extension is in
extension_list)
if (count processList) is 1 then
set processList to processList as alias as list
else
set processList to processList as alias list
end if
set initialCount to count folder aiFolder's document files
my (process_items from processList)
set processedCount to (count folder aiFolder's document files) -
initialCount
display dialog (processedCount as string) & " items were
converted." buttons ¬
{"Gracias"} default button 1 with icon 1
end tell
end convert_files
on run
display dialog "Welcome to the EPS to Illustrator AI converter." &
return & return & ¬
"Only EPS files are supported."
convert_files()
end run
------------------
Original script (for reference):
-- Illustrator EPS to AI Converter --
-- the list of file types which will be processed
-- eg: {"PICT", "JPEG", "GIFf", "TIFF"}
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"}
-- indicates file came from Illustrator
property app_type : {"ART5"}
global counter, sourceFolder, aiFolder, skipFolder, pathToSourceFolder
on run
display dialog "Welcome to the EPS to Illustrator AI converterer."
& return & return & ¬
"Only EPS files are supported." buttons {"OK"} default button 1
set sourceFolder to choose folder with prompt "Which folder would
you like to convert:"
set sourceFolder to sourceFolder as string
set pathToSourceFolder to sourceFolder as string
my checkSourcePath(pathToSourceFolder)
my display(pathToSourceFolder)
set aiFolder to choose folder with prompt "Choose AI destination
folder:"
set aiFolder to aiFolder as string
my display(aiFolder)
set skipFolder to choose folder with prompt "Choose skipped files
destination folder:"
set skipFolder to skipFolder as string
my display(skipFolder)
my conVert(sourceFolder)
end run
(* ========= This handler makes sure the sourceFolder is not
located on the Network ========= *)
on checkSourcePath(pathToSourceFolder)
try
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set theDisk to (first text item of pathToSourceFolder)
set AppleScript's text item delimiters to oldDelims
if (theDisk is not "Work") then
error "This script can not be run on a file/folder located on
the network."
end if
on error msg
my showError(msg)
end try
end checkSourcePath
-- This processes files or folders
on conVert(sourceFolder)
try
set counter to 0
repeat with i from 1 to the count of sourceFolder
set this_item to (item i of sourceFolder)
my display(this_item)
set item_info to the info for this_item
my display(item_info)
if (folder of the item_info is true) and ¬
(alias of the item_info is true) then
process_folder(this_item)
else if (alias of the item_info is false) then
process_item(this_item)
end if
end repeat
tell application "Finder"
activate
display dialog (the counter as string) & " items have been
converted to Illustrator AIs." buttons {"Gracias!"} default button 1
end tell
on error msg
my showError("Something happened during conVert")
end try
end conVert
-- this sub-routine processes folders
on process_folder(this_folder)
try
set these_items to list folder this_folder without invisibles
repeat with i from 1 to the count of these_items
set this_item to alias ((this_folder as text) & (item i of
these_items))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else 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
process_item(this_item)
end if
end repeat
on error msg
my showError("Something happened in process_folder")
end try
end process_folder
-- this sub-routine processes files
on process_item(this_item)
-- NOTE that the variable this_item is a file reference in alias
format
-- FILE PROCESSING STATEMENTS GOES HERE
try
tell application "Adobe Illustrator 10.0.3"
launch
if ((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)
and ¬
(the file this_item is type("ART5")) then
open this_item
save document 1 as Illustrator with options
{compatibility:Illustrator 10, compressed:true, embed all
fonts:true, PDF compatible:true} in aiFolder
else
move this_item to skipFolder
end if
close document 1 saving (no)
end tell
set counter to counter + 1
on error msg
my showError("Something happened in process_item")
end try
end process_item
on display(display_item)
display dialog "Item set to: " & (the display_item as string) ¬
buttons {"Gracias!"} default button 1 giving up after 7
end display
-- end finder tell
-- this handles formats error dialogs
on showError(msg)
display dialog msg buttons {"OK"} default button 1 with icon 0
end showError
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users
This email sent to email@hidden