The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. docx documents which have already been converted need to be manually removed before starting the script again. You can always test with, or run in several groups, with a smaller number of documents.Īlthough it could be added, I did not include any error handling around existing documents if the script fails and needs to be restarted, so be aware that the. Obviously this will vary based on size of the documents and the speed of the system it's run on. This would equate to ~6.5 minutes for 100 documents. I tested with a 10 document sample set with the documents ranging from 1 to 7 pages and on my system, a 16" 2019 MacBook Pro 2.3 GHz 8-Core Intel Core i9, and it took less than 40 seconds. Trying to multi-task while it's running, which is a no-no for this type of script! The value of the delay commands outside of the repeat loops need adjusting. For example, changes in the UI from one version of macOS to another or the target application. Tell application id "" to close document 1Īs the script uses UI Scripting it can be kludgy and prone to failure for a number of different reasons. # Wait for the 'Save' button to to disappear. # Wait for the 'Save' button to be available.īutton "Save" of sheet 1 of window 1 of ¬ # Click 'Save As… ⌥⇧⌘S' to save as a Pages document. # Wait for 'Opening "filename.docx"…' to disappear. # Give a moment for 'Opening "filename.docx"…' to appear. Repeat with thisDocument in theWordDocumentsList Let the script run uninterrupted until it's finished (or errors).Įxample AppleScript code: property theWordDocumentsList : missing value Click the Run button (right-pointing triangle icon) or press: ⌘R.Open Script Editor and copy and paste the example AppleScript code into a new document, click the Compile button (a hammer icon) or press ⌘K to make sure there are not any compile related issues.When naming the document make it something that is not within the names of the other documents to be processed. No other Pages documents should be opened. This is to allow Pages to say open while opening and closing the target documents, thus making the overall process take less time. ![]() Open Pages and create a blank document, saving it in the folder you want the other documents saved to, and then minimize it. ![]() docx documents in the target folder will be created to loop through. docx documents in their own folder so the target folder can be selected when the script runs. The use of this script requires some initial setup for it to work. ![]() 1 Assumes necessary and appropriate settings in System Preferences > Security & Privacy > Privacy have been set/addressed as needed.I do not have macOS Monterey or an M1 to test on, however, the example AppleScript code, shown below, was tested in Script Editor under macOS Catalina with Language & Region settings in System Preferences set to English (US) - Primary and worked for me without issue 1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |