Skip to content

Instantly share code, notes, and snippets.

@surajsau
Created May 24, 2020 10:20
Show Gist options
  • Save surajsau/3073bc3810baca2fa986c20135bbba1b to your computer and use it in GitHub Desktop.
Save surajsau/3073bc3810baca2fa986c20135bbba1b to your computer and use it in GitHub Desktop.
Applescript for storing the password mapping
on writePassword(title, passwordString)
try
-- (1)
set textToBeWritten to "\n" & title & ":" & passwordString
-- (2)
set documentsPath to path to documents folder as text
set passwordFile to documentsPath & "password.txt"
set the logFile to ((path to documents folder) as text) & "password.txt"
try
-- (3)
open for access file the logFile with write permission
write textToBeWritten to file the logFile starting at eof
close access file the logFile
on error
try
close access file the logFile
end try
end try
on error errMsg
display dialog passwordFile & errMsg
end try
end writePassword
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment