file alias without using prompt?

Can you make a file alias without using the prompt?

You can create a file alias to whatever path you like by simply declaring an alias with a path string parameter:


-- Get a file alias to a file known to be in the user's documents folder
set targetPath to ((path to documents folder) as string) & "MyFile.txt"
set myFileAlias to alias targetPath

ah, thats’s easy. Thanks
Too bad it isn’t working within Illustrator CS

This:

tell application “Illustrator CS”
set targetPath to ((path to documents folder) as string) & “MyFile.txt”
set myFileAlias to alias targetPath
end tell

gives an error.

(trying to make a “save as” script in illustrator CS for a single file during a loop)
http://bbs.applescript.net/viewtopic.php?t=10449
No much luck with that one yet

This is code that I’m currently using successfully in Illus. CS. YMMV.

–subroutine for saving files out as EPS, with parameters passed in
on EPSfileSave(savePath)
set fileName to (savePath as string) & “MyFile.eps”
try
open for access file (savePath & “MyFile.eps”)
close access file (savePath & “MyFile.eps”)
–workaround for a bug in CS with a save loop. try because the file could already exist.
end try
tell application “Illustrator CS”
save document 1 in file fileName as eps with options {compatibility:Illustrator 11, CMYK PostScript:true, embed linked files:true, PostScript:level 2, preview:color Macintosh}
end tell
end EPSfileSave

Try using a file specification instead of an alias for a file that doesn’t yet exist:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Hmmmm.still no luck. With the “save as” i meant to save the open document each time as a new seperate document. I’m using a loop because I want to change the properties of page items each time the document is saved. The increasing loop value alters the new document’s name. This is the basic idea.


repeat with counter from 1 to 5
	
tell application "Illustrator CS"
		
		set the stroke width of page item 1 of document 1 to counter
		
		set targetPath to (((path to desktop folder) as Unicode text) & "MyFile" & counter & ".eps") as file specification
		save document 1 in targetPath as eps with options {compatibility:Illustrator 11, CMYK PostScript:true, embed linked files:true, ¬
PostScript:level 2, preview:color Macintosh}
	end tell
end repeat


–workaround for a bug in CS with a save loop. try because the file could already exist.

Is there a bug with a save loop? I hope not. :frowning:

Strange because if I use the export function in the same way it works perfectly fine.
Like this:


set fileName to "MyFile" & counter
				set newFilePath to destinationPath & fileName & ".jpg"
				
					export current document to file newFilePath as JPEG with options ¬
						{class:JPEG export options ¬
							, quality:80 ¬
							, blur:0.0 ¬
							, horizontal scaling:200.0 ¬
							, vertical scaling:200.0 ¬
							, matte:false}


It would a bummer if there is not a way to export(save as) as a vector (eps,ai,pdf) file. :cry: