Jump to content

harrietb

Member
  • Posts

    2
  • Joined

  • Last visited

Reputation Activity

  1. Like
    harrietb reacted to deanishe in [Request]   
    You don't need the clipboard for this. You can pass the URL straight to TextEdit. This shows you how to create and save TextEdit documents:
     
    -- Called when script is executed on run (argv) -- Base name of the document without directory or file extension -- e.g. "Important Stuff" set documentName to "My Document" -- Where to save new files. Default is ~/Documents set saveDirectory to (path to documents folder) -- Make sure this is something TextEdit understands, e.g. ".rtf", ".txt" set fileExtension to ".rtf" set theText to my getSafariUrl() set thePath to my newFilePath(documentName, saveDirectory, fileExtension) createTextEditDocument(thePath, theText) end run -- Create a new document containing `theText` and save it at `thePath` on createTextEditDocument(thePath, theText) tell application "TextEdit" activate make new document with properties {text:theText} save document 1 in file thePath end tell end createTextEditDocument -- Return the URL of Safari's current tab on getSafariUrl() tell application "Safari" to return URL of front document end getSafariUrl -- Return an unused filepath by appending 1,2,3 etc. to `documentName` on newFilePath(documentName, saveDirectory, fileExtension) set theSuffix to 1 tell application "Finder" set fileName to (documentName as text) & fileExtension set thePath to (saveDirectory as text) & fileName repeat while item (thePath) exists set fileName to (documentName as text) & " " & (theSuffix as text) & fileExtension set thePath to (saveDirectory as text) & fileName set theSuffix to theSuffix + 1 end repeat end tell return thePath end newFilePath
×
×
  • Create New...