Skip navigation

Quick question to anyone who can help.

354 Views 8 Replies Latest reply: Nov 29, 2012 8:17 AM by Gfto RSS
Gfto Calculating status...
Currently Being Moderated
Nov 28, 2012 12:50 PM

I am a complete newbie who serached various forums to write this script:

 

This script allows the user to choose the file and create a text document with the file name without the path, and inserts it into 4 URLs

 

tell application "TextEdit"

    activate

    make new document

    set first_file to choose file without invisibles

    tell application "Finder" to set file_name to (name of first_file)

    set theDate to (current date) as text

    set AppleScript's text item delimiters to "_"

    set theTextString1 to "http://foobar1/" & file_name as text

    set theTextString2 to "http://foobar2/" & file_name as text

    set theTextString3 to "rtmpte://lfoobar3/" & file_name as text

    set theTextString4 to "http://foobar4/" & file_name as text

     set theAppleString1 to (text items 1 thru -3 of theTextString1) as text

    set theAppleString2 to (text items 1 thru -3 of theTextString2) as text

    set theAppleString3 to (text items 1 thru -3 of theTextString3) as text

    set theAppleString4 to (text items 1 thru -3 of theTextString4) as text    --set text of document 1 to theAppleString as text

  

    set text of document 1 to theDate & return & return & "PROGRESSIVE:" & return & return & (theAppleString1 & URL1) & return & return & "IPAD:" & return & return & (theAppleString2 & URL2) & return & return & "PROGRESSIVE AUDIO:" & return & return & (theAppleString3 & URL3) & return & return & "STREAMING AUDIO:" & return & return & (theAppleString4 & URL4) as text

    save document 1 in "/Users/mac3/Desktop/Untitled.txt"

end tell

 

I need this to run as as a app not a script.

 

Help!

  • Kappy Level 10 Level 10 (221,005 points)
    Currently Being Moderated
    Nov 28, 2012 12:56 PM (in response to Gfto)

    Save it as an application. It's an option of Applescript. When you save the script the option will be in the Save As dialog. If the script has already been saved, then select Duplicate from the File menu, then select Save.

     

    Screen Shot 2012-11-28 at 3.54.00 PM.png

  • adayzdone Level 2 Level 2 (150 points)
    Currently Being Moderated
    Nov 28, 2012 5:43 PM (in response to Gfto)

    Try:

     

    on open of theFiles

        set outFile to POSIX path of ((path to desktop as text) & "Untitled.txt")

        set {TID, text item delimiters} to {text item delimiters, "_"}

       

        repeat with aFile in theFiles

            tell application "System Events" to set file_name to aFile's name

            set theDate to (current date) as text

           

            set URL1 to " url 1"

            set URL2 to " url 2"

            set URL3 to " url 3"

            set URL4 to " url 4"

           

            set theTextString1 to "http://foobar1/" & file_name as text

            set theTextString2 to "http://foobar2/" & file_name as text

            set theTextString3 to "rtmpte://lfoobar3/" & file_name as text

            set theTextString4 to "http://foobar4/" & file_name as text

           

            set theAppleString1 to (text items 1 thru -3 of theTextString1) as text

            set theAppleString2 to (text items 1 thru -3 of theTextString2) as text

            set theAppleString3 to (text items 1 thru -3 of theTextString3) as text

            set theAppleString4 to (text items 1 thru -3 of theTextString4) as text

           

            set myText to theDate & return & return & "PROGRESSIVE:" & return & return & (theAppleString1 & URL1) & return & return & "IPAD:" & return & return & (theAppleString2 & URL2) & return & return & "PROGRESSIVE AUDIO:" & return & return & (theAppleString3 & URL3) & return & return & "STREAMING AUDIO:" & return & return & (theAppleString4 & URL4) as text

           

            do shell script "echo " & quoted form of myText & " >> " & quoted form of outFile

        end repeat

        set text item delimiters to TID

    end open

  • Frank Caggiano Level 7 Level 7 (22,760 points)
    Currently Being Moderated
    Nov 28, 2012 5:43 PM (in response to Gfto)

    on open of droppedFiles

         repeat with theFile in droppedFiles -- droppedFiles will always be a list even if only one file is dropped

     

              (your code dealing with theFile goes here)

     

     

         end repeat

    end open

  • red_menace Level 6 Level 6 (14,275 points)
    Currently Being Moderated
    Nov 28, 2012 5:53 PM (in response to Gfto)

    Typically you would do something like the following, where you can select files if the application is double-clicked, or drop items onto the application:

     

    on run -- the application was double-clicked
         open (choose file with multiple selections allowed)
    end run
    
    
    on open itemList -- items were dropped onto the application
         repeat with anItem in itemList -- step through each item in the list
              process(anItem)
         end repeat
    end open
    
    
    on process(anItem)
         -- do your stuff with an item
    end process
    


Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.