Copy link to clipboard
Copied
Hello,
I'm trying to use Terminal (command line) from Illustrator with ExtendScirpt.
I know it's possible in After Effects:
Just sharing my workaround (for Mac). This specific example shows how to zip folders.
With the help of AppleScript, I'm running terminal commands in Illustrator like this:
//Part 1: Extendscript part looks like this
//1. Get terminal command in form of string
var zipTerminalCommand = terminalCmdToZip();
//2. export terminal command string to a text doc
saveTextDoc(zipTerminalCommand)
//3. Run apple script app to use terminal command
//Change "YourUserName" part
myAppleScriptPath = "/Users/You
...
Copy link to clipboard
Copied
I'm just curious what kind of common options that this might provide, if it is doable..
Copy link to clipboard
Copied
My goal currently is to zip a folder. But also just handy in general to use command line 🙂
Copy link to clipboard
Copied
no, we have no such luxury. As an alternative you could write your terminal commands on a BAT (on Windows) file from jsx. There might be similar alternatives for mac.
or another way is to send the system calls to photoshop and have photoshop execute them.
Copy link to clipboard
Copied
You can use osascript command with AppleScript
Here is a typcal usage
//test.scpt
tell application "Adobe Illustrator"
activate
do javascript "alert(app.name)"
end tell
and command
osascript -l JavaScript test.scpt
Copy link to clipboard
Copied
Thank you! 🙂 I ended up using an option like this.
I'll post my solution in this thread for other people looking for solutions.
Copy link to clipboard
Copied
You could use the File objects execute method to execute commands by creating a bat/vbs file in Windows and a .command file on MAC.
-Manan
Copy link to clipboard
Copied
Just sharing my workaround (for Mac). This specific example shows how to zip folders.
With the help of AppleScript, I'm running terminal commands in Illustrator like this:
//Part 1: Extendscript part looks like this
//1. Get terminal command in form of string
var zipTerminalCommand = terminalCmdToZip();
//2. export terminal command string to a text doc
saveTextDoc(zipTerminalCommand)
//3. Run apple script app to use terminal command
//Change "YourUserName" part
myAppleScriptPath = "/Users/YourUserName/Desktop/YourAppleScript.app"
runAppleScript(myAppleScriptPath)
//=========================================
// FUNCITONS
//=========================================
//Returns the terminal command to zip a folder
function terminalCmdToZip(){
//Change "YourUserName" part
var myFoldersParent = "/Users/YourUserName/Desktop"; //path to the parent folder of the file you want to zip.
var nameOfFolderToBeZipped = "woo!"; //name of the folder being zipped
var nameOfNewZippedFolder = nameOfFolderToBeZipped + ".zip"; //Name of new zip, not a path.
var terminalCommand = 'cd ' + "'" + myFoldersParent + "'" + ' && zip -r -X ' + "'" + nameOfNewZippedFolder + "'" + ' ' + "'" + nameOfFolderToBeZipped + "'";
return terminalCommand
}
//exports a text doc with your terminal command
function saveTextDoc(saveThis) {
try{
var pathToClipboardDoc = "~/Documents/terminalCmd.txt";
var myDataLog = new File(pathToClipboardDoc);
myDataLog.open("w");
myDataLog.write(saveThis);
myDataLog.close();
}catch(err){}
}
//Runs AppleScript
function runAppleScript(pathToScript){
myScript = File(pathToScript)
if (myScript.exists) {
myScript.execute();
}
}
This is the AppleScript app you'll have to make for this to work
--Get info from text doc for variable
--Change the "YourUserName" part
set textDoc to POSIX file "/Users/YourUserName/Documents/terminalCmd.txt"
set textDocContents to (read textDoc)
--display dialog textDocContents
do shell script textDocContents
Feel free to share if you have a Windows workaround too.
Copy link to clipboard
Copied
Adobe extensions allow you to use NodeJS in panels. With access to NodeJS you can easily run command line commands. Do so is pretty easy. The challenge will be creating the CEP (Common Extension Protocol) panel. It's not really that hard and is, for the most part, the same as scripting but with a UI. There is a bit of a learning curve but it isn't terrible if you have some coding experience. CEP panels are built in HTML, CSS, and JS so anyone with basic web development experience cna learn it.