• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: a script for saving text from the clipboard to a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a script for saving text from the clipboard to a file


  • Subject: Re: a script for saving text from the clipboard to a file
  • From: "Laine Lee" <email@hidden>
  • Date: Tue, 28 Mar 2006 17:38:44 -0600

This isn't perfect, but it's what I could throw together in a hurry.

Save this script to your Big Cat Files folder, control click the desktop and select its name from your Scripts contextual menu.

property temppath : "/private/tmp/"
property startnum : 0
property clipname : "clip"
property add_on : ".txt"
property search_string : ""
property replacement_string : ""
property new_item_name : ""
property copypath : missing value

on main(s)
    set rootpath to s as string
    tell application "Finder"
        if last character of rootpath is ":" then
            tell me to set it_is_a_folder to true
        else
            set it_is_a_folder to false
        end if
        set thepathname to rootpath & clipname
    end tell
    set pos_filepath to POSIX path of rootpath as Unicode text
    set dest_file to (quoted form of (temppath & clipname & add_on))
    do shell script "pbpaste >" & space & dest_file
    tell application "Finder"
        set basename to clipname
        repeat
            try
                --display dialog (this_filepath & thesourcename & add_on)
                set name_target to alias (rootpath & clipname & add_on) --file name is already taken at destination if no error occurs.
                set startnum to startnum + 1
                set clipname to text returned of (display dialog "A file with that name already exists. You may enter a new name or cancel." default answer (basename & startnum))
            on error _error
                set startnum to 0
                if _error contains clipname then --if target is clear and source file can be copied from temp directory
                    tell me to do shell script "ditto" & space & dest_file & space & (quoted form of (pos_filepath & clipname & add_on))
                    exit repeat
                else -- if action is cancelled by user
                    exit repeat
                end if
            end try
        end repeat
    end tell
end main

--
Laine Lee
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: GUI scripting without permission
  • Next by Date: badly decomposed
  • Previous by thread: Re: a script for saving text from the clipboard to a file
  • Next by thread: vcal and ics files in OS9
  • Index(es):
    • Date
    • Thread