Tuesday, August 20, 2019

#1 2006-06-07 11:40:09 pm

Registered: 2005-05-30
Posts: 448

LaunchBar script/append text

LaunchBar has this script. I would like that it would append selected text in current application to rich text-file in hard coded location (meaning script dont ask location of text-file) and put separator between them:

old text here

----- date and time here --------

new text to here


-- Copyright (c) 2006 Objective Development
-- [url]http://www.obdev.at/[/url]
-- version 2

on run
   display dialog "This script appends arbitrary text to a text file. Please select a plain text file (with a .txt extension) in LaunchBar, press the Tab key, select the Append Text script via abbreviation search and press Return. You can then enter the text that shall be appended to the file." buttons {"OK"} default button 1 with icon 1
end run

on open listOfFiles
   set theFile to first item of listOfFiles
   set p to POSIX path of theFile
   if p ends with ".txt" then
       set defaultButton to "Append"
       set title to "Append Text:"
           set r to display dialog title default answer "" buttons {"Cancel", defaultButton} default button 2 with icon 1
           if button returned of r is defaultButton then
               set s to text returned of r
               do shell script "echo " & quoted form of s & " >> " & quoted form of p
           end if
       end try
       display dialog "This is not a text file." buttons {"OK"} default button 1 with icon 1
   end if
end open



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)