Hi, Shane,
Thanks for response, this little script work well.
I make a drag’n’drop script
script AppDelegate
property parent : class "NSObject"
property vectorFilesName : {} -- list of vector files
-- Raster images files formats
property rasterTypeList : {"8BPS", "8BPB", "TIFF", "PNGf"}
property rasterExtensionList : {"psd", "psb", "tif", "tiff", "png"}
property rasterTypeIDsList : {"public.png", "com.adobe.photoshop-image", "dyn.ah62d4rv4ge81a65c", "public.tiff"}
-- Vector images files formats
property vectorTypeList : {"EPSP", "PDF"}
property vectorExtensionList : {"ai", "eps", "pdf"}
property vectorTypeIDsList : {"com.adobe.illustrator.ai-image", "com.adobe.encapsulated-postscript", "com.adobe.pdf"}
--------------------------------------------------
-- 2. Droplet select files/folders --
--------------------------------------------------
on |application|:theApp openFiles:fileList
set vectorFilesName to {}
set rasterFilesName to {}
set workResult to my setFilesList:fileList -- procedure for set list of dropped items, sort them and count
if workResult is false then
tell me
activate
display alert ¬
"Sorry, application got an error:" message ¬
"Unable to set parameters for dropped items" & return & "and will be terminated" & the error_number & ". " & the error_message
end tell
return
end if
set vectorCount to count of vectorFilesName
set rasterCount to count of rasterFilesName
set stringVectorCount to vectorCount as text
fldVectorCount's setStringValue_(stringVectorCount)
set stringRasterCount to rasterCount as text
fldRasterCount's setStringValue_(stringRasterCount)
if vectorCount < 1 and rasterCount < 1 then
secondWindow's orderFront:me
firstWindow's orderOut:me
else if vectorCount > 0 then
-- display dialog "You have select " & vectorCount & " vector files"
end if
end |application|:openFiles:
-----------------------------------------------------------
end script
here I get a list of files, then sort them by type and write in variable
vectorFilesName
-------------------------------------------------------
-- Open files with Adobe Illustrator --
-------------------------------------------------------
on saveVectorAsJpeg_()
try
set countItems to count of vectorFilesName
on error the error_message number the error_number
tell me
activate
display alert ¬
"Sorry, an error has occured “" message ¬
"Unable to get the item_info: " & the error_number & ". " & the error_message
end tell
end try
repeat with aFile in vectorFilesName
tell application "Finder"
try
set droppedPath to aFile as string
set the itemInfo to info for droppedPath -- Get full file info
set this_extension to the name extension of itemInfo -- Extension
on error the error_message number the error_number
set this_extension to ""
tell me
activate
display alert ¬
"Sorry, module \"openWithAI\" got an error “" message ¬
"Unable to get the info from item: " & return & return & the error_number & ". " & the error_message
end tell
end try
--------------------------------------
-- VERY IMPORTANT !!!! --
--------------------------------------
try
set hfsPath to (((aFile as text) as POSIX file) as text) -- convert POSIX path to HFS path
on error the error_message number the error_number
tell me
activate
display alert ¬
"Sorry, an error has occured “" message ¬
"Unable to create hfsPath “ " & the error_number & ". " & the error_message
end tell
end try
try
set vectorFile to alias hfsPath -- convert HFS to alias (for open with Illustrator)
on error the error_message number the error_number
tell me
activate
display alert ¬
"Sorry, an error has occured “" message ¬
"Unable to create this_item as alias of hfsPath “ " & the error_number & ". " & the error_message
end tell
end try
end tell
tell application "Adobe Illustrator"
set user interaction level to never interact
-- set display dialogs to never
-- Here we try to open selected vector items
with timeout of 600 seconds
try
open vectorFile with options {create artboard with artwork bounding box:true} without dialogs
on error the error_message number the error_number
tell me
activate
display alert ¬
"Sorry, an error has occured in saveFilesAsEPS(thisItem) “" message ¬
"Illustrator cant open the file: " & the error_number & ". " & the error_message
end tell
close current document saving no -- Close current document
return false
end try
end timeout
set docRef to the current document
set docWidth to (width of docRef)
set docHeight to (height of docRef)
set docName to name of docRef
if docWidth > docHeight then
set scaleValue to ((currentPreviewSize * 100) / docWidth) * scaleResolution
else
set scaleValue to ((currentPreviewSize * 100) / docHeight) * scaleResolution
end if
try
set newFileName to outputFolder & docName & "." & this_extension
--set testName to newFileName as string
--set testName to «class ktxt» of (testName as record)
on error the error_message number the error_number
tell me
activate
display alert ¬
"Sorry, an error has occured in module saveVectorAsJPEG() “" message ¬
"Unable to set name for output file: " & the error_number & ". " & the error_message
end tell
close current document saving no
return false
end try
with timeout of 1800 seconds
try
export current document to file newFileName as JPEG with options ¬
{class:JPEG export options, quality:80, matte:false, artboard clipping:true}
on error the error_message number the error_number
tell me
activate
display better alert ¬
"Sorry, an error has occured in module saveVectorAsJPEG() “" message ¬
"Illustrator can't save the file: " & the error_number & ". " & the error_message
end tell
close current document saving no
return false
end try
end timeout
close current document saving no
end tell
end repeat
end saveVectorAsJpeg_
Here i open files with Ai. (This a part of script)
OMG, wall of text
So it was not in the reel - dunce sat in the cockpit …