Is it possible to run a mac os shell command within javascript in Indesign like in photoshop

New Here ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hey Community, is it possible to run a shell command within javascript in Indesign
like in photoshop for example "app.system('say "hello world"')" is there a Indesign equivalent ?
Thanks for help.

Views

111

Likes

translate

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

Adobe Community Professional , Apr 14, 2021 Apr 14, 2021
Not with Javascript, but you can run an Applescript snippet with doScript in Javascript.

Likes

translate

Translate

Translate
Adobe Community Professional ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

I've moved this from the Using the Community forum (which is the forum for issues using the forums) to the InDesign forum so that proper help can be offered.

Likes

translate

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
Enthusiast ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hello,

 

Here's an example of what @TᴀW is taking about that I use to zip the Document Fonts folder.....hope this helps!

var doc = app.documents[0];

myDocFolder = doc.filePath;
var myDocumentFonts = Folder(myDocFolder.fsName + "/Document fonts/");  
if (!myDocumentFonts.exists) {
exit();
}  

CreateFontsZip();
function CreateFontsZip(){
var myFontsZipFolder = myDocumentFonts;
var myFontsZipDestination = doc.filePath;
 var myDocumentFontsZipName = "Document fonts";
   app.scriptArgs.setValue("zip", myFontsZipFolder)
    app.scriptArgs.setValue("zipName", myDocumentFontsZipName)
     app.scriptArgs.setValue("zipLocation", myFontsZipDestination)
     var myFontsZipScript = ''' tell script args
   set myZip to get value name "zip"
 set theZipName to get value name "zipName"
set destFold to get value name "zipLocation"
do shell script ("ditto -c -k --sequesterRsrc " & quoted form of POSIX path of myZip & " " & quoted form of POSIX path of destFold & "" & quoted form of POSIX path of theZipName & "" & ".zip")
end tell '''
app.doScript(myFontsZipScript, ScriptLanguage.applescriptLanguage);
}

Regards,

Mike

Likes

translate

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
Adobe Community Professional ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hi Thomas,

app.system() is not available with ExtendScript for InDesign.

Would file.execute() work for your purpose?

 

Regards,
Uwe Laubender

( ACP )

Likes

translate

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
New Here ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hi Uwe,

thanks for your fast response but the "file.execute()" don´t fits my purpose.

I m looking for an "easy" way to use some shell commands in combination with Indesign and Javascript.

I try to avoid to execute a file.

Regards,

Thomas

 

 

Likes

translate

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
Adobe Community Professional ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Not with Javascript, but you can run an Applescript snippet with doScript in Javascript.

Likes

translate

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
New Here ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Thanks TaW and the Community to point me in the right direction.

 

To execute a shell command with javascript in photoshop you can use this code:

app.system('say "hello world"')

 

To execute a shell command with javascript in indesign you can use this code:
Pitfall: if you are using double quotes (") in your shell command you have to use
"quoted form of" like in this example.
myScript = ' do shell script "say " & quoted form of "hello world" '
app.doScript(myScript, ScriptLanguage.applescriptLanguage);
 
best regards
-Thomas

Likes

translate

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