Last active
December 30, 2016 11:05
-
-
Save getflourish/cb4bd536b219395d71e1ef621ded1647 to your computer and use it in GitHub Desktop.
Applescript to convert AppleWorks 6 documents to Microsoft Word files. This script will open each file of the source folder with AppleWorks and export each via the "Save as…" dialog to the output folder. The export format of the code example here is based on a German version of MacOS, but can be changed to any other format presented in the drop …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main() | |
on main() | |
set source_folder to choose folder with prompt "Choose a source folder." | |
set output_folder to choose folder with prompt "Choose an output folder." | |
set suffix to ".doc" | |
tell application "Finder" | |
set theFiles to (files of entire contents of source_folder) as alias list | |
end tell | |
set export_translator to "Word Mac 98, 2001 Dokument" | |
set export_translator_TEXT to my |TEXT|(export_translator) | |
repeat with aFile in theFiles | |
tell application "Finder" | |
set fileName to name of aFile | |
set fileExt to name extension of aFile | |
end tell | |
set newFileName to fileName & suffix | |
set src to aFile's POSIX path | |
set dst to (path to output_folder)'s POSIX path & newFileName | |
set srca to src as POSIX file as alias | |
set dsta to touch(dst) as POSIX file as alias | |
tell application "AppleWorks 6" | |
--return export translators | |
open srca | |
tell document 1 | |
save in dsta using translator export_translator_TEXT | |
close saving no | |
end tell | |
end tell | |
end repeat | |
end main | |
on touch(f) | |
do shell script "touch " & f's quoted form | |
return f | |
end touch | |
on |TEXT|(u) | |
(* | |
string u : source text | |
return data : «data TEXT...» representing u converted to MACROMAN encoding | |
*) | |
do shell script "u=" & u's quoted form & "; printf '%s' \"$u\" | iconv -f UTF-8 -t MACROMAN | xxd -p" | |
run (run script " | |
script | |
«data TEXT" & result & "» | |
end script") | |
end |TEXT| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment