Can Automator translate multiple files?

Posted:
in Mac Software edited March 2014

Hi. I have a very large number of old Apple Works files. I need to translate them to Pages, so I can move on. Just now I am using Mac OS X 10.6.8. Snow Leopard, only because I can still run Apple Works.

Can I use Automator to open and translate a large number of files? (And then move on to Mavericks).

Something like: Take the files in this folder - Open them - Translate each of them to Pages - Place them in this or that folder.

I haven't used Automator much. It doesn't seem so easy to operate to me. 

Comments

  • Reply 1 of 10
    tallest skiltallest skil Posts: 43,388member

    My only concern with a mass-Appleworks script is you losing the file name for each individual file. 



    How large is ‘very large’ here?

  • Reply 2 of 10

    It's about 1000 Apple Works text files.

    Could you give an indication of how I could make the script?

  • Reply 3 of 10
    tallest skiltallest skil Posts: 43,388member

    So you’re still on Snow Leopard, which means you don’t have the newest Pages, correct?

     

    Crack open AppleScript Editor and paste this in. Then copy ONE of your AppleWorks files to the Desktop or whatever and hit run. Let it go through and see if it converts it correctly. If it does, do ‘em all.

     

    on run

        choose file with multiple selections allowed

        my doyourduty(result as list)

    end run

     

    on open theFiles

        my doyourduty(theFiles)

    end open

     

    on doyourduty(theFiles)

        

        tell application "Pages"

            repeat with aFile in theFiles

                if (aFile as text) ends with ".cwk" then

                    open aFile

                    set docName to name of front document

                    -- Remove .cwk extension.

                    set prevTIDs to AppleScript's text item delimiters

                    set AppleScript's text item delimiters to ".cwk"

                    -- Add .pages extension.

                    set docName to first text item of docName & ".pages"

                    set AppleScript's text item delimiters to prevTIDs

                    -- Get folder that dropped file exists in.

                    tell application "Finder"

                        set sourceFolder to (container of aFile) as Unicode text

                    end tell -- Finder

                    -- Save file to folder that dropped file exists in.

                    set docPathAndName to sourceFolder & docName

                    save front document in docPathAndName

                    close front document

                end if

            end repeat

        end tell

    end doyourduty

     

    If, uh… if that doesn’t work, copy this instead.

     

    on run

        choose file with multiple selections allowed

        my doyourduty(result as list)

    end run

     

    on open theFiles

        my doyourduty(theFiles)

    end open

     

    on doyourduty(theFiles)

        

        tell application "Pages"

            repeat with aFile in theFiles

                if (aFile as text) ends with ".cwk" then

                    open aFile

                    set docName to name of front document

                    -- Remove .cwk extension.

                    set prevTIDs to AppleScript's text item delimiters

                    set AppleScript's text item delimiters to ".cwk"

                    -- Add .pages extension.

                    set docName to first text item of docName & ".pages"

                    set AppleScript's text item delimiters to prevTIDs

                    -- Get folder that dropped file exists in.

                    tell application "Finder"

                        set sourceFolder to (container of aFile) as Unicode text

                    end tell -- Finder

                    -- Save file to folder that dropped file exists in.

                    set docPathAndName to sourceFolder & docName

                    save front document in docPathAndName

                    close front document

                end if

            end repeat

        end tell

    end doyourduty

  • Reply 4 of 10

    Thank you. I will try it out.

  • Reply 5 of 10

    I appreciate your effort Tallest Skil!

    But it is not easy to have AppleScript open the files, as they are created in AppleWorks 3.0.

    That means Pages cannot open them.

     

    I am beginning to think the only way is to go through everything by hand. 

    It is all my work through 11 years as a journalist, so I think I am going to do it in order to preserve it.

    When I convert it to Pages it will be searchable in Spotlight.

  • Reply 6 of 10
    tallest skiltallest skil Posts: 43,388member
    Originally Posted by Sorensen View Post

    But it is not easy to have AppleScript open the files, as they are created in AppleWorks 3.0.

     

    Yowza. You wouldn’t happen to have a copy of AppleWorks 6.2.9 around, would you?

  • Reply 7 of 10

    Yes, of course. I use AppleWorks 6.2.9.

    It opens the files, but for every file, one have to confirm with Enter, that you want to open it. That might be difficult in an AppleScript.

  • Reply 8 of 10
    tallest skiltallest skil Posts: 43,388member
    Originally Posted by Sorensen View Post

    Yes, of course. I use AppleWorks 6.2.9.

    It opens the files, but for every file, one have to confirm with Enter, that you want to open it. That might be difficult in an AppleScript.


     

    I really feel that there’s a simple way to do this, I just don’t know it.

  • Reply 9 of 10
    osnolaosnola Posts: 1member
    Hello,
    https://discussions.apple.com/thread/5455245?start=40&tstart=0 contains many scripts which seem to do what you want

    Note: If the layout of these documents is simple enough, the latest version of LibreOffice will also open them
  • Reply 10 of 10

    Thank you, Osnola!

Sign In or Register to comment.