Change this script from folder selection to selected finder items

Trying to batch convert .eps files to .ai files. In best of worlds I would like to make sure they are CS6-version, CMYK and that the .eps file is trashed. The .ai file should be placed in the same place as the old .eps file.

But anyway if its just possible to make the modification of this script so that it takes whatever files I have selected in the finder and runs the script thats good enough (I use Keyboard Maestro to trigger the script with a hotkey).

This is the script I use, and it works fine (only thing is that it prompts for both in and out folder):

set FileSample to (choose folder with prompt “Choose an input folder.”) as string

set MyFolderA to (choose folder with prompt “Choose an output folder.”) as string

tell application “Finder” to set theFiles to files of folder FileSample whose name extension is in {“eps”} or kind contains “EPS”

repeat with oneFile in theFiles
tell application “Adobe Illustrator”
activate

	open (oneFile as alias) without dialogs
	
	tell front document
		
		set docBaseName to name
		
		if (characters -4 thru -1 of docBaseName) as string is ".eps" then
			set docBaseName to (characters 1 thru -5 of docBaseName) as string
		end if
		
		set newFileName to (MyFolderA & docBaseName & ".ai") as string
		
		
		try
			set locked of every layer to false
		end try
		
		try
			set locked of every page item to false
		end try
		
		
		set theTexts to every text frame
		set selection to theTexts
		convert to paths (every text frame)
		
	end tell
	
	save front document in file newFileName as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 11, compressed:true, embed ICC profile:false, embed linked files:true, font subset threshold:100.0, PDF compatible:true}
	close front document saving no
	
end tell

end repeat

tell application “Adobe Illustrator”
activate
display dialog “Done.” buttons {“OK”} default button 1
end tell

Browser: Safari 600.8.9
Operating System: Mac OS X (10.10)

Try this:


tell application "Finder"
	set theFiles to selection as alias list
	set MyFolderA to folder of item 1 of theFiles as text
end tell

tell application "Adobe Illustrator"
	activate
	
	repeat with oneFile in theFiles
		
		open (oneFile as alias) without dialogs
		
		tell front document
			
			set docBaseName to name
			
			if (characters -4 thru -1 of docBaseName) as string is ".eps" then
				set docBaseName to (characters 1 thru -5 of docBaseName)
			end if
			
			set newFileName to (MyFolderA & docBaseName & ".ai") as text
			
			try
				set locked of every layer to false
			end try
			
			try
				set locked of every page item to false
			end try
			
			
			set theTexts to every text frame
			set selection to theTexts
			convert to paths (every text frame)
			
		end tell
		
		save front document in file newFileName as Illustrator with options {class:Illustrator save options, compatibility:Illustrator 11, compressed:true, embed ICC profile:false, embed linked files:true, font subset threshold:100.0, PDF compatible:true}
		close front document saving no
		
	end repeat
	
	display dialog "Done." buttons {"OK"} default button 1
	
end tell

I’ve moved the repeat loop inside the Illustrator tell block.

HTH

Thanks! Works Perfect :slight_smile:

Glad to hear :slight_smile: