AppleScript Error Message I am looking for a way to batch-convert/bulk-convert .doc files into .docx files. I found this TidBITS Talk that references a Redit thread for an AppleScript (AS) and a dead DropBox link for an Automator integration of mentioned AS in a WorkFlow.
However, when I run the script in Automator or Script Editor I get a Syntax Error - Expected end of line, etc. but found identifier. Inside the script compatibility is highlighted (as being the issue, I guess).
What can be done to correct the error?
Find the new version as suggested by @CJK of the entire script here below:
property theList : {&quot;doc&quot;}

on run {input, parameters}
        set output to {}
        tell application &quot;Microsoft Word&quot; to set theOldDefaultPath to get default file path file path type documents path
        repeat with theDoc in input
        tell application &quot;System Events&quot;
            set theFolderPath to the path of theDoc's container
            set theExtension to name extension of theDoc
            set theName to name of theDoc
        end tell
        if theExtension is in theList then
            set l to the length of theName
            set exl to the length of theExtension
            set n to l - exl - 1

            set theFilename to (text 1 through n of theName) &amp; &quot;.docx&quot;

            tell application &quot;Microsoft Word&quot;
                set default file path file path type documents path path theFolderPath
                open theDoc
                set theActiveDoc to the active document
                save as theActiveDoc file format format document file name theFilename without maintain compatibility
                close theActiveDoc
            end tell

            set end of output to the POSIX path of (theFolderPath &amp; theFilename)
        end if
        end repeat

        tell application &quot;Microsoft Word&quot; to set default file path file path type documents path path theOldDefaultPath
        return output
end run

Find here below a screenshot of Script Editor after compilation without the word compatibility (trying to compile the code with this word gives me the same error message as the one at the beginning of this post):


System used:

macOS Catalina 10.15.5
MacBook Pro (13&quot;, 2019, 2.8 GHz Quad-Core Intel Core i7, 16 GB RAM, Intel Iris Plus Graphics 655 1536 MB)
Microsoft Word Version 16.39 (20071300)
Script Editor Version 2.11 (208)
Automator Version 2.10 (492)
You want folders… I got your folders right here…
To use, select a folder and run the script.
Notes: I used Word to open each document as that made it easier to match file with container, which should also reduce issues with how long it takes to open multiple files. There isn't any error correction so if your selection isn't a folder….
-- Save all 'doc' within folder structure as 'docx' in same folder
-- Create list of each 'doc' file and its containing folder
set fKind to &quot;Microsoft Word 97 - 2004 document&quot;
tell application &quot;Finder&quot;
    set topFolder to selection as alias
    set refList to a reference to entire contents of topFolder
    
    set bList to {}
    set docList to every item of refList whose kind is fKind
    repeat with ea in docList
        set c to container of ea as alias as text
        copy {name of ea, c} to end of bList
    end repeat
end tell

-- Open each 'doc', save in same folder, close doc
tell application &quot;Microsoft Word&quot;
    set oldDefaultPath to get default file path file path type documents path
    
    repeat with b in bList
        -- b in bList example {&quot;filename.doc&quot;, &quot;Mac:Users:username:Documents:docFolder1:deepFolder2:&quot;}
        set sName to first item of b
        set sPath to second item of b
        set default file path file path type documents path path (sPath)
        
        open sPath &amp; sName
        save as document sName file name (sName &amp; &quot;x&quot;) file format format
        close document 1 saving no
        
    end repeat
    set default file path file path type documents path path oldDefaultPath
end tell