• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Use Command Line From Illustrator Script?

Explorer ,
May 06, 2020 May 06, 2020

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:

system.callSystem(yourCommand)
 
And in Photoshop:
app.system(yourCommand)
 
Does anyone know if there's a way to run Terminal from Illustrator?
Thank you! 🙂
TOPICS
Scripting

Views

4.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , May 07, 2020 May 07, 2020

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
...

Votes

Translate

Translate
Adobe
Participant ,
May 06, 2020 May 06, 2020

Copy link to clipboard

Copied

I'm just curious what kind of common options that this might provide, if it is doable..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 07, 2020 May 07, 2020

Copy link to clipboard

Copied

My goal currently is to zip a folder. But also just handy in general to use command line 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2020 May 06, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2020 May 06, 2020

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 07, 2020 May 07, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2020 May 06, 2020

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 07, 2020 May 07, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 20, 2020 Oct 20, 2020

Copy link to clipboard

Copied

LATEST

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines