Copy link to clipboard
Copied
Hi All,
I need to call a applescript inside the javascript, so i write a code like this:
Do the following
See the following links for more information on osascript and command file
https://scriptingosx.com/2022/05/launching-scripts-4-applescript-from-shell-script/
...Copy link to clipboard
Copied
The doScript method is Illutrator is used to play actions. See the following
https://www.indesignjs.de/extendscriptAPI/illustrator-latest/#Application.html#d1e49416__d1e50891
You could try by creating a file method to the applescript file and then calling the execute method
-Manan
Copy link to clipboard
Copied
Hi Mannan,
Thanks for your logics, but if i execute the file(apple script) using file.execute() function, its just opened in apple script editor its not running, we need to manualy triger it to run, thats the only drawback init. i think so..
Copy link to clipboard
Copied
Do the following
See the following links for more information on osascript and command file
https://scriptingosx.com/2022/05/launching-scripts-4-applescript-from-shell-script/
https://www.skptricks.com/2019/08/create-executable-command-file-in-mac-os.html
-Manan
Copy link to clipboard
Copied
Donāt use AppleScript to manipulate files. Thereās no need. ExtendScriptās built-in File and Folder objects can do that.
Copy link to clipboard
Copied
I agree, and would just do all of the work within ExtendScript since you are already running it.
A few notes about the code below...
var myFolder = new Folder(Folder.desktop + "/myMacFolder/");
var myFile = new File(Folder.desktop + "/myMacFile.ai");
var myFileCopy = new File(myFolder + "/myMacFile.ai");
myFile.copy(myFileCopy);
Reference:
Folder Objects: https://extendscript.docsforadobe.dev/file-system-access/folder-object.html
File Objects: https://extendscript.docsforadobe.dev/file-system-access/file-object.html
Copy link to clipboard
Copied
Hi hhas,
Before i used the extended script for this file manipulations, but extendedScript file functionalities will change the created and modified time and date while we run the scripts, thats why i prefer apple script in-between which will retain the modified and created date plus time.
Copy link to clipboard
Copied
Your problem is that if Illustratorās ExtendScript API doesnāt provide a `doScript` function for running AppleScripts, and it doesnāt provide a `system()` like call for running shell scripts, and it doesnāt even provide a `Socket` object, then I think youāre about out of luck.
You might consider executing your .jsx scripts from AppleScript using `do javascript jsxScript with arguments {arg1, arg2, ā¦}`, allowing AppleScript to take care of the bits you donāt want to do yourself. Or you might write a CEP panel, and have that execute both.
Personally Iād just grimace and bear it for now, use `File` and `Folder` despite their limitations, and bide your time until UXP makes its public appearance for AI. UXP is built on Node.js, which is way more capable than moldy ExtendScript, in large part due to its massive third-party library support (albeit sometimes of dubious quality). That includes far better standard libraries for accessing the filesystem, and 3rd-party libraries for interacting with AppleScriptable apps directly and just about everything else.
Fingers crossed we all start migrating off ancient, creaky ExtendScript onto modern Node.js sooner rather than later. Letās see what MAX 2022 brings in October, I guess.
Copy link to clipboard
Copied
Thank you manan, hhas and jduncan for your suggestions and options for solving this script. Right now i using manan suggestion to execute applescript as a seperate file from illustrator javascript! hope adobe will provide the feasibilities in indesign for illustrator also, that would be more smart and effeicient way to execute commands in a single call of functionš!
Copy link to clipboard
Copied
Hi @Muthu5FC5 ,
found this discussion very interesting.
Thanks for all the feedback from all participants!
Just wanted to add an exotic alternative solution:
One could use InDesign triggered from Illustrator through ExtendScript's BridgeTalk module for doing the doScript() with the appropriate parameter. Search e.g. the InDesign forum for code samples with BridgeTalk if you are not familiar with it. Documentaion about BridgeTalk:
Messaging framework API reference
https://extendscript.docsforadobe.dev/interapplication-communication/messaging-framework-api-referen...
BridgeTalk class
https://extendscript.docsforadobe.dev/interapplication-communication/bridgetalk-class.html
Another thing, to avoid the ugly string concatenation one could write the AppleScript code as string this way, with a "tripple-fencing" so to say:
var myAppleScriptString =
'''
tell application "Finder"
set myFolder to a reference to folder (name of startup disk & "' + myMacFolder + '")
set myFile to a reference to file (name of startup disk & "' + myMacFile + '")
tell myFile
duplicate to myFolder
end tell
end tell
''';
Of course, not a very practical solution from the perspective of an arbitrary user. But an option you could consider if you run Illustrator and InDesign side by side on a machine you have full control to. Especially if you are the current user.
Regards,
Uwe Laubender
( Adobe Community Expert )