Skip to content

Instantly share code, notes, and snippets.

Last active October 1, 2018 12:31
What would you like to do?
Applescript : Reading and Writing Files
on writeTextToFile(theText, theFile, overwriteExistingContent)
set theFile to theFile as string
set theOpenedFile to open for access file theFile with write permission
if overwriteExistingContent is true then set eof of theOpenedFile to 0
write theText to theOpenedFile starting at eof
close access theOpenedFile
return true
on error
close access file theFile
end try
return false
end try
end writeTextToFile
on writeFile(theContent, writable, fileName)
set this_Story to theContent
tell application "Finder"
set a to container of (path to me) as string
set b to (a & fileName) as string
log b
end tell
writeTextToFile(this_Story, b, writable)
end writeFile
-- writeFile("text to write", false, "test.csv") as text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment