I’m a little familiar with AppleScript more than with JavaScript & need help converting the script below into AS. I need to choose a folder of files, open each of the files in it and import the styles from the source document which I partially have below but not sure how to import the styles via AS.
var MyFolderWithFiles = Folder.selectDialog ("Choose a folder");
var sourceFile = File.openDialog("Choose the styles source");
var myFiles = MyFolderWithFiles.getFiles("*.indd");
for(i = 0; i < myFiles.length; i++) {
theFile = myFiles[i];
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var targetDoc = app.open(theFile, true);
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
targetDoc.importStyles(ImportFormat.CHARACTER_STYLES_FORMAT, sourceFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE);
targetDoc.importStyles(ImportFormat.PARAGRAPH_STYLES_FORMAT, sourceFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE);
targetDoc.close(SaveOptions.YES);
}
The AS version I have so far:
set source_folder to choose folder with prompt "Select folder containing InDesign docs to which to import character style \"C-XXX\" and paragraph style \"P-XX\"."
set source_folder to choose folder with prompt "Select a source doc"
tell application "Finder" to set theFiles to files of source_folder whose name extension is "indd"
repeat with oneFile in theFiles
tell application id "com.adobe.InDesign"
set user interaction level of script preferences to never interact
activate
set myDocument to open (oneFile as alias)
tell myDocument
-- import the character & paragraph styles from source .
--=========
close myDocument saving yes
--=========
tell application id "com.adobe.InDesign"
set user interaction level of script preferences to interact with all
end tell
--=========
end tell
end tell
end repeat
Model: iMac (Retina 5K, 27-inch, Late 2015)
AppleScript: Version 2.10 (194)
Browser: Safari 604.5.6
Operating System: Mac OS X (10.13 Developer Beta 3)