Good Day All!
I quite a newbie in applescripting… I have created a script that resaves a .tif file into .eps using illustrator 10. What I want is the user will select the tiff original folder and the eps destination folder… it selects all the tif files in the original folder open it in illustrator resaves it into eps and move that eps to the destination folder. On my script the eps file staying on the original folder.
set the topLevelFolder to choose folder with prompt "Source Folder?" as string
tell application "Finder"
set AllFiles to name of every file of folder topLevelFolder as list
end tell
set myPath to choose folder with prompt "Destination folder?" as string
tell application "Finder" to set fileName to AllFiles
tell application "Adobe Illustrator 10"
repeat with i in AllFiles
set OpenThisDoc to ((topLevelFolder as string) & i) as alias
open OpenThisDoc
if (count of documents) > 0 then
set myInteractLevel to user interaction level
set user interaction level to never interact
set myPath to file path of document 1 as string
if myPath ends with ".tif" then
try
repeat with myPage from 1 to 1
open alias myPath with options {page:myPage}
set myNewPath to myPath
repeat with myCharNum from (count of characters of myNewPath) to 1 by -1
if character myCharNum of myNewPath = "." then
if myCharNum > (count of characters of myNewPath) - 5 then set myNewPath to (text of characters 1 thru (myCharNum - 1) of myNewPath) as string
exit repeat
end if
end repeat
set myNewPath to myNewPath & ".eps"
save document 1 in file myPath as eps
close document 1 saving no
end repeat
end try
end if
set user interaction level to myInteractLevel
end if
end repeat
end tell
all of this script is just cut and paste… totally no idea but it worked
thanks in advance
Model: iMac g3 candy blue
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
AppleScript can filter the files for you so you’re not checking every file, but just those that are tiffs:
set the topLevelFolder to choose folder with prompt "Source Folder?" as string
tell application "Finder"
try
set AllFiles to (files of topLevelFolder where its file type is "TIFF") as alias list
on error -- the line above will error if there is only one file, so the line below is used.
set AllFiles to (files of toplevlefolder where its file type is "TIFF") as alias as list
end try
end tell
--> a list of aliases to every tiff file in the designated folder including those in internal folders.
That elimates the need to check. I don’t have Illustrator and you don’t ask a question, so I’ll stop.
As far as the Illustrator stuff goes, this format will now open each and save it as an eps file in the same folder it came from. If you want to save it somewhere else, more is required.
tell "Adobe Illustrator 10"
repeat with i in AllFiles
open i
save i as eps
close i saving no
end repeat
end tell
sorry about that I just wanted the script I made to simply resave the tiff files in the original folder and convert that tiff files to EPS moved to the destination folder… its like a batch tiff resaver script
thanks in advance
when I run my original script the eps is saving in the original folder… did I scripted something wrong?
thanks again
Sorry again, I read this late… how?
thanks again
set sourceFolder to choose folder with prompt "Choose the TIF source folder" as string
set targetFolder to choose folder with prompt "Choose the EPS target folder" as string
-- Thanks for this bit Adam
tell application "Finder"
try
set tiffFiles to (files of sourceFolder where its file type is "TIFF" or its name extension is "tif") as alias list
on error -- the line above will error if there is only one file, so the line below is used.
set tiffFiles to (files of sourceFolder where its file type is "TIFF" or its name extension is "tif") as alias as list
end try
end tell
tell application "Adobe Illustrator"
set user interaction level to never interact
repeat with aFile in tiffFiles
open aFile without dialogs
set theName to name of document 1
set savePath to (targetFolder & (text 1 thru -5 of theName) & ".eps") as string
save document 1 in file savePath as eps
close document 1 saving no
end repeat
end tell
Adam and James,
Thank you soooo much!!!
this really helped me.
More power to you guys and Macscripter… a place where applescript problems are solved
James,
One last favor how can I code this as a folder action? hehe I never tried scripting a folder action before…
thanks in advance
Model: iMac g3 candy blue
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)