Skip to content

Instantly share code, notes, and snippets.

@derickfay
Last active December 22, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derickfay/6445713 to your computer and use it in GitHub Desktop.
Save derickfay/6445713 to your computer and use it in GitHub Desktop.
Strip the user home directory from a filename in Applescript
tell application "Skim"
set theFile to file of document 1 as string
set theHome to path to home folder as string
set theFilePath to my replaceText(theHome, "", theFile)
end tell
on replaceText(find, replace, someText)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set someText to text items of someText
set text item delimiters of AppleScript to replace
set someText to "" & someText
set text item delimiters of AppleScript to prevTIDs
return someText
end replaceText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment