Copy link to clipboard
Copied
I have next to no knowledge of javascript, nor where to go for help? I have a very simple Applescript that I would like to convert into javascript.
For starters, does anybody know the following javascript equivalent for this line of code:
set myVersion to version of application id "com.adobe.InDesign" as string
The other part of the script I might be able to figure out on my own. Except at some point I'll have to find a PC user to provide the file path to the InDesign's Preference folder's "en_US" folder.
Using a File.openDialog(); would get around not knowing the hardcoded file path, but the defeats the purpose and efficiency of the script. I want the end user to be able to assign a keyboard shortcut to this script, which would then open all their InDesign library files with one simple keyboard command.
--Determine what version of InDesign running as string
tell application id "com.adobe.InDesign"
activate
set myVersion to version of application id "com.adobe.InDesign" as string
--display dialog myVersion
if myVersion starts with "6." then
set myVersion to "version 6.0"
else if myVersion starts with "7.0" then
set myVersion to "Version 7.0"
else if myVersion starts with "7.5" then
set myVersion to "Version 7.5"
else if myVersion starts with "8." then
set myVersion to "Version 8.0"
else if myVersion starts with "9." then
set myVersion to "Version 9.0"
else if myVersion starts with "10.0" then
set myVersion to "version 10.0"
else if myVersion starts with "11.0" then
set myVersion to "version 11.0"
end if
end tell
tell application "Finder"
try
set this_folder to folder ((path to current user folder as Unicode text) & "Library:Preferences:Adobe InDesign:" & myVersion & ":en_US:Valpak_Libraries:")
on error
tell application "SystemUIServer"
activate
display dialog "Could not find the VPLibraries folder. Or maybe it is in the wrong location?" & return & return & "Make sure all of your library {.indl files} reside in:" & return & return & "Admin>Library>Preferences>Adobe InDesign>" & myVersion & ">en_US>Valpak_Libraries" buttons {"Cancel"} default button "Cancel" with icon stop
end tell
end try
end tell
set theList to {".indl"}
tell application id "com.adobe.InDesign"
activate
repeat with i in this_folder
try
set theName to name of i
if theName contains theList then
open i
end if
end try
end repeat
end tell
Hi Jeff,
for ExtendScript (JavaScript) you can lookup properties, values and functions etc.pp. here:
Jongware's excellent DOM documentation. Go for the chm files, if you want to search offline:
And here Gregor Fellenz's DOM documentation:
InDesign ExtendScript API (8.0)
InDesign ExtendScript API (10.0)
InDesign ExtendScript API (11.0)
If you lookup "application", you'll notice, that there is a "version" property for the object "app".
...var myVersion = "version"+" "+parseFloat(app.
Copy link to clipboard
Copied
Hi Jeff,
for ExtendScript (JavaScript) you can lookup properties, values and functions etc.pp. here:
Jongware's excellent DOM documentation. Go for the chm files, if you want to search offline:
And here Gregor Fellenz's DOM documentation:
InDesign ExtendScript API (8.0)
InDesign ExtendScript API (10.0)
InDesign ExtendScript API (11.0)
If you lookup "application", you'll notice, that there is a "version" property for the object "app".
var myVersion = "version"+" "+parseFloat(app.version);
alert(myVersion);
No ifs and else ifs necessary.
Uwe
Copy link to clipboard
Copied
Laubender,
I can't thank you enough! I greatly appreciate you taking the time to answer and respond to my post, the links and information you provided are tremendously helpful.
You are correct about not requiring the else and ifs. However I will have to brush up on javascript functions and learn how to convert something like 8.1 into 8.0 since the file path of the folder I am going to eventually target will be 8.0 (not 8.1, despite 8.1 being the actual version number).
Thanks again,
-Jeff
Find more inspiration, events, and resources on the new Adobe Community
Explore Now