Wildcards within AppleScript

I'm generating HTML and CSS automatically from Scrivener, a Mac-only author's writing program (a very good one).
I've got a lot of documents to process and I want to tweak the CSS beyond what Scrivener automatically generates, and at the same time make all documents adhere to a single standard. In order to make this happen I've created an AppleScript to work to run through the HTML text to do a stream of search and replace functions. So far, this works very well.
However, there are some segments where the string between one predictable delimiter and another is unpredictable. What's called for is a wildcard to select all the text between the delimiters and replace it with something else.
Someone elsewhere has said there's no syntax for wildcards within AppleScript. Not sure of the truth of that. What's the procedure to achieve my objective?
Much appreciated.

Ah - you are wanting to extract HTML elements. This is a little bit different than wildcards and substrings, and dropping some script snippets into an application tell statement. There are some existing scripts out there for extracting HTML, as well as those that read text files. BBEdit is also scriptable, so I think this wound up being a little more difficult than it needed to be. Anyway, now that I know more about what you are wanting to do, give the following script a try - I didn't know anyone else used a version of BBEdit as old as mine (TextWrangler works too).
The following script takes the text of the front BBEdit window, extracts the HTML elements specified, and creates a new window with the results:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 335px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run
tell application "BBEdit 6.5.3"
get the text of the front window
my GetHTMLElements(the result, "<script", "</script>", false)
set text of (make new window) to the result as text
end tell
end run
to GetHTMLElements(SomeText, OpenTag, CloseTag, ContentsOnly)
return a list of the specified HTML elements in SomeText
parameters - SomeText [text]: the text to look at
OpenTag [text]: the opening tag (can be a partial)
CloseTag [text]: the complete closing tag
                            ContentsOnly [boolean]: return just the contents, or the entire element
returns [list]: a list of the HTML elements found - {""} if none
set TextBuffer to SomeText as text
set CurrentOffset to 1 -- the current offset in the text buffer
set ElementList to {} -- the list of elements found
try
repeat
set Here to offset of OpenTag in (text CurrentOffset thru -1 of TextBuffer) -- start of opening tag
if Here is 0 then exit repeat -- not found
set CurrentOffset to CurrentOffset + Here
set CurrentTag to CurrentOffset - 1 -- mark the start of the element
if OpenTag does not end with ">" then -- find the close of the tag
set Here to offset of ">" in (text CurrentOffset thru -1 of TextBuffer) -- end of opening tag
if Here is 0 then exit repeat -- not found
set CurrentOffset to CurrentOffset + Here
end if
set Here to CurrentOffset
set There to offset of CloseTag in (text CurrentOffset thru -1 of TextBuffer) -- end tag
if There is 0 then exit repeat -- not found
set CurrentOffset to CurrentOffset + There - 2
set There to CurrentOffset
if ContentsOnly then
set the end of ElementList to text Here thru There of TextBuffer & return
else
set the end of ElementList to text CurrentTag thru (There + (length of CloseTag)) of TextBuffer & return
end if
end repeat
on error ErrorMessage number ErrorNumber
if (ErrorNumber is -128) or (ErrorNumber is -1711) then -- nothing (user cancelled)
else
activate me
display alert "Error " & (ErrorNumber as string) message ErrorMessage as warning buttons {"OK"} default button "OK"
end if
end try
if ElementList is {} then set ElementList to {""}
return ElementList
end GetHTMLElements
</pre>

Similar Messages

  • Find / replace within applescript

    I am working on a script to change the file path of a hyperlink
    tell application "Adobe InDesign CS5"
       tell active document
           set listOfButtons to every button
           repeat with thisButton in listOfButtons
               tell thisButton
                   set FilePath to file path of goto anchor behaviors
                   return FilePath
               end tell
           end repeat
       end tell
    end tell
    the answer I get is : {"Content:Pricelist:Catalog:Interactief:BE:21_ES_Ventielen_be_dig.indd"}
    Now I want to change "BE" into "FR" and "be" into "fr"
    (in the future I will have to change it to other suffix, so it would be nice if this can be included as well )
    Can anyone help we to do this?

    Mark,
    I had to change the final command to
    set file path of goto anchor behaviors of thisButton to NewPath
    I changed the script a little bit because I noticed that "to items 1 thru 4" didn't work on all the files
    this is the new script:
    tell application "Adobe InDesign CS5"
              tell active document
                        set listOfButtons to every button
                        repeat with thisButton in listOfButtons
                                  tell thisButton
                                            set FilePath to file path of goto anchor behaviors
                                            set ASTID to AppleScript's text item delimiters -- Store settings
                                            set ButtonPath to (item 1 of FilePath) as string
                                            set AppleScript's text item delimiters to ":" -- Everything splits at this character
                                            set PathBits to text items of ButtonPath -- Slice it…
                                            repeat with i from 1 to count PathBits
                                                      considering case
                                                                if item i of PathBits is "NL" then
                                                                          set item i of PathBits to "FR"
                                                                end if
                                                      end considering
                                            end repeat
                                            set TempPath to items 1 thru i of PathBits as string
                                            set AppleScript's text item delimiters to "_" -- Now everything splits at this character
                                            set DocBits to text items of TempPath
                                            repeat with j from 1 to count DocBits
                                                      considering case
                                                                if item j of DocBits is "nl" then
                                                                          set item j of DocBits to "fr"
                                                                end if
                                                      end considering
                                            end repeat
                                            set NewPath to items 1 thru j of DocBits as string
                                            set file path of goto anchor behaviors of thisButton to NewPath
                                  end tell
                        end repeat
              end tell
    end tell
    Now I just have to make it possible to do this for all the buttons in a document. First I want to make it possible to choose the original path and doc...
    This is what I've got at this moment:
    tell application "Adobe InDesign CS5"
              tell active document
      --choose path
                        set PathOrigArray to {"BE", "FR", "NL", "EX", "DE"}
                        set PathOrigID to choose from list PathOrigArray with prompt "Selecteer de map met originele bestanden." OK button name "Update book" without multiple selections allowed
                        set PathNewArray to {"FR", "NL", "EX", "DE"}
                        set PathNewID to choose from list PathNewArray with prompt "Selecteer de map met nieuwe bestanden." OK button name "Update book" without multiple selections allowed
      --choose doc
                        set DocOrigArray to {"be", "fr", "nl", "ex", "de"}
                        set DocOrigID to choose from list DocOrigArray with prompt "Selecteer de suffix van de originele bestanden." OK button name "Update book" without multiple selections allowed
                        set DocNewArray to {"fr", "nl", "ex", "de"}
                        set DocNewID to choose from list DocNewArray with prompt "Selecteer de suffix van de nieuwe bestanden." OK button name "Update book" without multiple selections allowed
                        set listOfButtons to every button
                        repeat with thisButton in listOfButtons
                                  tell thisButton
                                            set FilePath to file path of goto anchor behaviors
                                            set ASTID to AppleScript's text item delimiters -- Store settings
                                            set ButtonPath to (item 1 of FilePath) as string
                                            set AppleScript's text item delimiters to ":" -- Everything splits at this character
                                            set PathBits to text items of ButtonPath -- Slice it…
                                            repeat with i from 1 to count PathBits
                                                      considering case
                                                                if item i of PathBits is PathOrigID then
                                                                          set item i of PathBits to PathNewID
                                                                end if
                                                      end considering
                                            end repeat
                                            set TempPath to items 1 thru i of PathBits as string
                                            set AppleScript's text item delimiters to "_" -- Now everything splits at this character
                                            set DocBits to text items of TempPath
                                            repeat with j from 1 to count DocBits
                                                      considering case
                                                                if item j of DocBits is DocOrigID then
                                                                          set item j of DocBits to DocNewID
                                                                end if
                                                      end considering
                                            end repeat
                                            set NewPath to items 1 thru j of DocBits as string
                                            set file path of goto anchor behaviors of thisButton to NewPath
                                  end tell
                        end repeat
              end tell
    end tell
    The problem is that he doesn't change the items... what I am doing wrong?

  • Applescript help: using commandline within applescript

    I'm trying to use applescript to take the results from a shell script and then put the results into the finder comments of the file. I believe I can use:
    do shell script "/Users/wesM/Documents/Development/AVWSamples/test.sh"
    to run the script, but I can't get it to work. test.sh is and executable file, and has the following line in it:
    mdls -name kMDItemCodecs -name kMDItemPixelWidth -name kMDItemPixelHeight 19Never.mov | awk '{ print "Codec "$1}' > out
    The script works fine. I want to take the results file (out), and then put it into the finder comments, I'm guessing with:
    set comment
    Is this possible? Can I get the filename to a shellscript from applescript?
    Is there a better/easier way to do this?
    Thanks for any help.

    I should have read the mdls command you used. i just copied and pasted it. you need to provide the correct path to the movie file. you didn't which is why the command failed. there is nothing to escape in that name so it's not an issue. and yes you can turn it into an application so that when you drop a file onto it it will automatically do this to all dropped files.
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on open these_items
    tell application "Finder"
    repeat with this_item in these_items
    set fpath to quoted form of POSIX path of this_item
    set comment of this_item to do shell script "mdls -name kMDItemCodecs -name kMDItemPixelWidth -name kMDItemPixelHeight " & fpath
    end repeat
    end tell
    end open</pre>
    save this as an application. if you want the original shell command use that in the above instead.

  • Shell commands in applescript noob

    Hi all this is my first post in these forums and I come seeking help with a certain script I'm writing for my current college job. The purpose of the script is to install creative cloud from a server and this is as far as I've got. First I can get as far as setting the correct directory in the server by doing:
    do script "cd /Volumes/applications/Mac/'Adobe Creative Cloud'/'Enterprise - enduser'/Build"
    now when I press run the terminal screen pops up just fine with no errors in the right directory. However I've been reading up that to do other commands in the same shell I must do do shell script. When doing this however terminal doesn't do...anything. The reason why I was trying this is because my next command would be initiating the install which is the command:
    "installer -verbose -pkg 'enterprise_Install.pkg' -target /" with adminitrator privilages
    Now my question is how would formulate this within applescript? Thanks.

    do shell script "cd /Volumes/applications/Mac/'Adobe Creative Cloud'/'Enterprise - enduser'/Build ;  installer -verbose -pkg 'enterprise_Install.pkg' -target / with administrator privilages"
    You got the double quote in the wrong place.
    do shell script "cd /Volumes/applications/Mac/'Adobe Creative Cloud'/'Enterprise - enduser'/Build ;  installer -verbose -pkg 'enterprise_Install.pkg' -target / " with administrator privilages
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set unixDesktopPath to POSIX path of "/System/Library/User Template/"
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "sudo ls -l  " & quotedUnixDesktopPath with administrator privileges
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run

  • Find & replace part of a string in Numbers using do shell script in AppleScript

    Hello,
    I would like to set a search-pattern with a wildcard in Applescript to find - for example - the pattern 'Table 1::$*$4' for use in a 'Search & Replace script'
    The dollar signs '$' seem to be a bit of problem (refers to fixed values in Numbers & to variables in Shell ...)
    Could anyone hand me a solution to this problem?
    The end-goal - for now - would be to change the reference to a row-number in a lot of cells (number '4' in the pattern above should finally be replaced by 5, 6, 7, ...)
    Thx.

    Hi,
    Here's how to do that:
    try
        tell application "Numbers" to tell front document to tell active sheet
            tell (first table whose selection range's class is range)
                set sr to selection range
                set f to text returned of (display dialog "Find this in selected cells in Numbers " default answer "" with title "Find-Replace Step 1" buttons {"Cancel", "Next"})
                if f = "" then return
                set r to text returned of (display dialog "Replace '" & f & "' with " default answer f with title "Find-Replace Step 2")
                set {f, r} to my escapeForSED(f, r) -- escape some chars, create back reference for sed
                set tc to count cells of sr
                tell sr to repeat with i from 1 to tc
                    tell (cell i) to try
                        set oVal to formula
                        if oVal is not missing value then set value to (my find_replace(oVal, f, r))
                    end try
                end repeat
            end tell
        end tell
    on error number n
        if n = -128 then return
        display dialog "Did you select cells?" buttons {"cancel"} with title "Oops!"
    end try
    on find_replace(t, f, r)
        do shell script "/usr/bin/sed 's~" & f & "~" & r & "~g' <<< " & (quoted form of t)
    end find_replace
    on escapeForSED(f, r)
        set tid to text item delimiters
        set text item delimiters to "*" -- the wildcard 
        set tc1 to count (text items of f)
        set tc2 to count (text items of r)
        set text item delimiters to tid
        if (tc1 - tc2) < 0 then
            display alert "The number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string."
            error -128
        end if
        -- escape search string, and create back reference for each wildcard (the wildcard is a dot in sed) --> \\(.\\)
        set f to do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g;s/\\*/\\\\(.\\\\)/g' <<<" & quoted form of f
        -- escape the replacement string, Perl replace wildcard by two backslash and an incremented integer, to get  the back reference --> \\1 \\2
        return {f, (do shell script "/usr/bin/sed -e 's/[]~$.^|[]/\\\\&/g' | /usr/bin/perl -pe '$n=1;s/\\*/\"\\\\\" . $n++/ge'<<<" & (quoted form of r))}
    end escapeForSED
    For what you want to do, you must have the wildcard in the same position in both string. --> find "Table 1::$*$3", replace "Table 1::$*$4"
    Important, you can use no wildcard in both (the search string and the replacement string) or you can use any wildcard in the search string with no wildcard in the replacement string).
    But, the number of wildcard in the replacement string must be equal or less than the number of wildcard in the search string.

  • Using Wildcards in Mapping Script

    Hi everybody, im new in FDM and i have some doubts about mapping scripts.
    I have to recreate this Hyperion Translation Rule into FDM:
    ACC_SAP              tm_sap     Reverse Sign         UD4
    N21099Z300     {NULL}     FALSE     CD1
    D31199Z000     {NULL}     FALSE     CD1
    ????99     *     FALSE     CD
    ACC_SAP is the source account
    TM_SAP will be loaded into UD5 (as look up)
    How could i manage with a like mapping?
    I guess using a script but im not sure how to use wildcards within scripts, is it possible?
    Another related question, in a explicit mapping, how can i manage with NULL values if i want to assign them [None] value, do i have to put NULL in th source field?
    BR and thanks

    Thanks KellyDGreen. With the exampl shown is as you say but what if tm_sap has wildcards?
    F.i
    ACC_SAP TM_SAP TARGET_CUSTOM4
    999? 123? 198276
    Suppose that TM_SAP has been stored in UD5. Source dimensions are different from target dimension so i have to do it via script, dont I?
    BR
    Francisco

  • Is there a way to trigger batch process via Applescript or Javascript?

    Based on what I've found so far on the internet, the answer is no. The Applescripts I've found so far that attempt to run a batch process don't work for me in either Acrobat Pro 8 or Pro 9.
    I've been using Applescript to automate a process that starts in InDesign (create PDFs), then goes to Acrobat to set open options (I've got a batch process for that but can't find a way to trigger it). If I can get that to work, I'll attempt to automate the task of using a Photoshop droplet to create JPEGs of a specific size from these PDFs.
    I've settled on InDesign CS3 for creating single-page PDFs from a multiple-page document, partly because I could not find a scriptable way to do this in Acrobat. I know just enough about Applescript to be dangerous. I know much less about Javascript.
    Any help would be appreciated.
    Thanks,
    Kevin Stauffer

    Kevin some thing like this for Photoshop should aid you
    set Todays_Date to do shell script "date \"+%d-%m-%y\""
    -- Create new folder to save to
    tell application "Finder"
    set Raster_Images to make new folder at desktop with properties ¬
    {name:"Rasterized PDF's " & Todays_Date}
    end tell
    -- Set Photoshop settings
    tell application "Adobe Photoshop CS2"
    activate
    set display dialogs to never
    set User_Rulers to ruler units of settings
    set ruler units of settings to pixel units
    -- set background color to {class:CMYK color, cyan:0, magenta:0, yellow:0, black:0}
    -- set foreground color to {class:CMYK color, cyan:0, magenta:0, yellow:0, black:100}
    end tell
    -- Get list of PDF's
    set The_Question to "Do you want to include all the subfolders" & return & "within your folder selection?"
    set The_Dialog to display dialog The_Question buttons {"No", "Yes"} default button 1 with icon note
    if button returned of The_Dialog is "Yes" then
    set Input_Folder to choose folder with prompt "Where is the top level folder of PFD's?" without invisibles
    tell application "Finder"
    set File_List to (files of entire contents of Input_Folder whose name extension is "pdf")
    end tell
    else
    tell application "Finder"
    set Input_Folder to choose folder with prompt "Where is the folder of PFD's?" without invisibles
    set File_List to (files of Input_Folder whose name extension is "pdf")
    end tell
    end if
    set File_Count to count of File_List
    if File_Count = 0 then
    display dialog "This folder contains no PDF files to rasterize!" giving up after 2
    end if
    -- Loop through the files in list
    repeat with This_File in File_List
    tell application "Finder"
    set The_File to This_File as alias
    end tell
    -- Tiger (OSX.4) shell call to count the pages
    set Page_Count to my PDF_Pages(POSIX path of The_File)
    if the result is not false then
    -- Loop Photoshop through the page count
    repeat with i from 1 to Page_Count
    tell application "Adobe Photoshop CS2"
    activate
    open The_File as PDF with options ¬
    {class:PDF open options, bits per channel:eight, constrain proportions:true, crop page:trim box, mode:CMYK, page:i, resolution:300, suppress warnings:true, use antialias:true, use page number:true}
    set Doc_Ref to the current document
    tell Doc_Ref
    flatten
    -- Enter your name strings into two enties below
    -- Case sensitive stings
    -- do action "My Action" from "My Action Set"
    -- New file naming options
    set Doc_Name to name
    set ASTID to AppleScript's text item delimiters
    set AppleScript's text item delimiters to " "
    set Doc_Name to text items of Doc_Name
    set AppleScript's text item delimiters to "_"
    set Doc_Name to Doc_Name as string
    set AppleScript's text item delimiters to "-"
    set Doc_Name to text item 1 of Doc_Name
    set AppleScript's text item delimiters to ASTID
    if Page_Count = 1 then
    set New_File_Name to (Raster_Images as string) & Doc_Name & ".tif"
    else
    set File_Number to ""
    repeat until (length of (File_Number as text)) = (length of (Page_Count as text))
    if File_Number = "" then
    set File_Number to i
    else
    set File_Number to "0" & File_Number
    end if
    end repeat
    set New_File_Name to (Raster_Images as string) & Doc_Name & "_" & File_Number & ".tif"
    end if
    end tell
    save Doc_Ref in file New_File_Name as TIFF with options {byte order:Mac OS, embed color profile:false, image compression:LZW, save alpha channels:false, save layers:false}
    close current document without saving
    end tell
    end repeat
    end if
    end repeat
    -- Set ruler units back to user prefs
    tell application "Adobe Photoshop CS2"
    set ruler units of settings to User_Rulers
    end tell
    beep 3
    -- OSX Tiger shell handler
    on PDF_Pages(This_PDF)
    try
    do shell script "/usr/bin/mdls -name kMDItemNumberOfPages" & space & quoted form of This_PDF & " | /usr/bin/grep -o '[0-9]\\+$'"
    on error Error_Message number Error_Number
    if Error_Number is 1 then
    display alert "Page Count Unavailable" message "The page count for " & This_PDF & " is unavailable." giving up after 3
    return false
    else
    display alert "Error " & Error_Number message Error_Message giving up after 3
    return false
    end if
    end try
    end PDF_Pages
    and something like this to perform JavaScript from within AppleScript for Acrobat
    You would be better talking to the JavaScript Experts on how to use addScript() to get your doc level scripts in.
    property Default_Path : (path to desktop folder as Unicode text) as alias
    property JavaScript : "var re = /.*\\/|\\.pdf$/ig; var filename = this.path.replace(re,''); try { for (var i = 0; i < this.numPages; i++) this.extractPages( { nStart: i, cPath: filename+'_' + (i+1) +'.pdf' }); } catch (e) { console.println('Aborted: '+e) }" as text
    set The_PDF to choose file default location Default_Path ¬
    with prompt "Where is the multi-page PDF?" without invisibles
    tell application "Adobe Acrobat 7.0 Professional"
    activate
    open The_PDF
    tell active doc
    do script JavaScript
    close saving yes
    end tell
    end tell

  • Spolight result and Applescript in harmony

    Hello,
    I'm new to Applescript and what I'm interested in doing seems like a great job for it.
    I've made a spotlight search on a single folder in the file system and saved the search to its default location (/Users/alex/Library/Saved Searches/searchQuery). My search was for all pdf files in and beneath its directory. My list of results contain many duplicates and I'd like to thin it so that it shows or selects only unique files (this means if there are duplicates, show only one copy).
    I was thinking that if I iterate through the list of results by comparing the name of the file with subsequent files along with its file size this should give me the result I'm looking for. Also, some of the duplicate files appear like abc-1.pdf or abc-2.pdf where these dash integers ("-1") is appended before the prefix so not to overwrite a file of the same name when I first downloaded them.
    Finally, I'd like to make a copy of these files so that all are unique in a new directory. I plan on making a backup of these documents.
    As an aside, I've already made the search and selected what I consider to be unique files by using simple mouse clicks while holding the command key. It's a painful thing to do when you have hundreds of these files. Even worse, I found out you can't copy files from a Spotlight search result - it gives you a system beep error.
    Thanks to all who spend the time reading this lengthy thread. I appreciate your time and energy
    Cheers,
    Alex

    Yes, you're right @Camelot. I had anticipated comparing file sizes along with the file name to check for duplicates. My file count that I want to sift through is in the hundreds and not thousands so I think this is sufficient for my purposes.
    I've heard that calling a bash script from applescript to check for file details can be slow and was curious to know if you can run a regex comparison of the file name from applescript and also check the file size within applescript as well. Again, I guess since I have only a few hundred files to compare with, this slow down may be negligible and not worth the hassle of maybe doing it all within applescript.
    What I have so far looks like:
    (* Get array of paths to selected folders in following try statement *)
    set pathsList to {}
    try
    set pathsList to ¬
    choose folder with prompt ¬
    "Select as many folders as you like:" with multiple selections allowed
    on error eStr number eNum partial result rList from badObj to expectedType
    do shell script "echo " & eStr
    end try
    (* The above method uses the colon (:) as a delimiter for subsequent folders. I'd like to get paths like /Users/alex/fileA:/Users/alex/fileB and so on... *)
    (* Failing the above, I don't mind removing the "with multiple selections allowed" portion to get one path from the user instead. *)
    (* Next I want to perform a spotlight search for files of pdf type within each path *)
    set resultsList to {}
    repeat with currentPath in pathsList
    (* do Spotlight Search here *)
    (* How do I retain the list of results in resultsList? *)
    end repeat
    set listOfNames to {}
    set uniqueFilesList to {}
    tell application "Finder"
    repeat with currentFile in resultsList
    set currentFileName to (the name of currentFile)
    (* And do the same for the file size: *)
    set currentFileSize to (the size of currentFile)
    (* Make certain that the currentFile is an original and store in uniqueFilesList if so *)
    set flag to 0
    repeat with uniqueFile in uniqueFilesList
    set uniqueFileName to (the name of uniqueFile)
    set uniqueFileSize to (the size of uniqueFile)
    if uniqueFileName contains currentFileName then
    set flag to 1
    if uniqueFileSize is not equal to currentFileSize then
    set flag to 0
    end if
    end if
    if flag = 1 then
    break
    end if
    end repeat
    if flag = 0 then (* add to final list *)
    copy currentFolderName to the end of listOfNames
    end if
    set lastFolderName to currentFolderName
    end repeat
    end tell
    Any fixes you may think of for this piece of code would be appreciated.
    Regards,
    Alex

  • Applescript to change Page setup in PowerPoint for Mac

    Very new to AppleScript.    I'd like to change the Page Setup to "On-screen show (16:9)".  Within PowerPoint it is under File>Page Setup>Size>Slides sized for : On-screen Show (16:9).    I did find within AppleScript that the Slide Size is a Property of the Page Setup Class within the Microsoft PowerPoint Suite.  It is also listed under the Application Class >Command Bar Class>Command Bar Control.  The Page Setup inherits it's properties from Base Object.
    I tried to manually record the process of opening a PPT file and choosing File>Page Setup>Size>On-screen show (16:9) but it only recorded the process to activate PPT and open the file.
    I wrote this script:
    tell application "Microsoft PowerPoint"
         activate
         open {file"MacBook Pro Hard Drive:Users:Patrick:Desktop:AppScript.pptx"}
    set slide size to "on-screen show"
    end
    I get the error "Syntax Error :  A property can't go after this identifier" and "slide size" is highlighted.
    I'm stuck......Slide Size is a property of the Page Setup Class.  How should I write this ?
    Script Editor V. 2.7(176) and PowerPoint for Mac 2011

    http://answers.microsoft.com/en-us/mac/forum/macpowerpoint?tm=1366105550521.
    That's where the PowerPoint experts hang out...
    Clinton

  • LabVIEW Database Connectivity Toolkit Parameterized Query Property Wildcard

    Hi,
    within my LabVIEW application I successfully implemented a SQL statement
    like
    SELECT *
    FROM table_name
    WHERE property 1 = 123
    AND property2 = "abc"
    with help of the Database Connectivity Toolkit. I first created a parameterized
    query, then set each parameter and afterwards executed this query.
    But now I want to use wildcards within this statement. Does anybody know
    how to use wildcards with both integer properties and string properties?
    Is this possible while using the normal parameterized query vi?
    Thanks in advance for your help.
    Regards
    Michael

    Hi Michael
    You can use "LIKE":
    SELECT * FROM table_name WHERE property 1 LIKE '12%'
    % represents multiple characters (e.g. entries with property 1 123 but also 1240 would be selected)
    _ represents one character
    Hope this helps.
    Thomas
    Message Edited by becktho on 09-05-2005 11:57 AM
    Using LV8.0
    Don't be afraid to rate a good answer...

  • Why doesn't this simple AppleScript work?

    Hi. I'm trying to change my desktop background using some AppleScript from the command line:
    osascript -e 'tell application "Finder" to set desktop picture to POSIX file "~/Pictures/Some Picture.jpg"'
    But, I get this:
    33:48: execution error: Finder got an error: AppleEvent handler failed. (-10000)
    I also tried it this way:
    osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"~/Pictures/Some Picture.jpg\""
    ...and got the same result.
    So, I then tried this AppleScript (essentially the same thing?) from within AppleScript editor:
    tell application Finder
              set desktop picture to POSIX file "~/Pictures/Some Picture.jpg"
    end tell
    and got a syntax error:
    A class name can’t go after this application constant or consideration.
    I have reason to believe that this works for others, but I can't seem to make it work. Also, if anyone can suggest another way to change the desktop background from the cammand line, that would be helpful too.

    Thanks, that worked great in AppleScript Editor, and when I ran the .applescript file with osascript. However, when I tried to make the same changes from the commandline, I got this:
    33:48: execution error: Finder got an error: Can’t make "Pictures:Some Picture.jpg" into type file. (-1700)
    It would be easier if I could pass a command line argurment to my script, that is now working thanks to you (I know there is a way to do this but how?). Also it would have to be a a UNIX style path (like '/path/to/file.jpg' not 'path:to:file.jpg of home' or 'file.jpg of to of path').

  • Add user to Netinfo database with Applescript

    Does anyone have an example Applescript that would allow us to add a user to the local Netinfo Database on a computer? We would like to push this to a lab of computers to add a new local user to all computers at once.
    thanks

    See this article for some Terminal commands which can be used. To run these from an AppleScript, use code such as:
    set the_password to "password"
    do shell script "nicl . -create /users/username" password the_password with administrator privileges
    continuing the code for the rest of the commands in step 4 the article modified as needed. If you aren't creating a group, skip the line to append the user to the group and remove the group name from the chmod. The passwd command is interactive and cannot be executed from within AppleScript.
    (18463)

  • Applescript to run SQL Server stored procedure on Mac

    Hello All,
    I'm new to applescript. I've a stored procedure in SQL server that generates a uniqque Jobnumber. I need to run this stored procedure from applescript and display the new job number to the user. How can I achieve this using Applescript? Is there any other alternative? Any suggestion/inputs are welcome.
    Thanks

    There's no simple, direct MySQL interface within AppleScript - that is, you can't (easily) connect to your database directly and execute the stored procedure.
    The commonest solution to this is to use the command line mysql interface via do shell script.
    set myData to (do shell script "/usr/local/mysql/bin/mysql -u USERNAME -pPASSWORD -e '<SQL statement here>'")
    There's a lengthy discussion, including examples, at http://macscripter.net/viewtopic.php?id=24721

  • IPhoto Choose Photo AppleScript

    There has to be a simple answer to this question, but I can't find it anywhere.
    When writing AppleScripts for the Finder, there is a "choose file" command which opens a file select dialog.
    I'm trying to write a script for iPhoto, but I can't find an equivalent command to open the iPhoto photo select dialog. Is there one?
    Thanks in advance for your help!

    I knew it would be a simple answer!
    I'm working on an export script for iPhoto that will eventually do a bunch of things, but at this stage I'm just playing around with manipulating some of the data like titles, comments etc., and I was just trying to make it all work from within AppleScript.
    I also tried Automator, trying to pass the selected photos from the "Ask For Photos" dialog to an AppleScript. I tried creating an application that does nothing but "Ask For Photos" and then using that in a script, too. In both cases, the script refused to manipulate (or even just display) any of the titles, comments, dates or anything else from the chosen photos.
    Everything I've tried to do with photos I've manually selected in iPhoto has worked, so I'll just have to do it that way. It's no big deal, I just wanted to see if I could do it this other way.
    Thanks for your quick answer!

  • Fuzzy AppleScript Dialogs

    Not sure if this is the right place for this to be, but here goes.
    I use AppleScript for a ton of stuff. One thing that's been slightly bothering me is that it's not been updated for the rMBP. In the Editor itself, the "Run" button is clearly still fuzzy, and dialog boxes are fuzzy as well.
    Is there something I can do besides wait on Apple to fix this?

    @slrandall
    I can confirm your issue:
    I am now using a rMBP 11.3 (Mid 2014) with OS X 10.9.5, and previously used a MBP 2.1 with OS X 10.6.8 (Late 2006).
    I too noticed that when running compiled Applescripts apps that were compiled on my non-retina MBP that they use non-retina resolutions and thus are blurry.
    There is no apparent fix within AppleScript or other native Apple Software:
    I tried to recompile them with the current Applescript Editor (Version 2.6.1 (152.1); AppleScript 2.3.2) as apps, but they still only remain non-retina.
    But luckily there is a fix with a 3rd party freeware:
    http://retinizer.mikelpr.com/  successfully scales up standard UI elements and fonts to retina resolution of any app dropped on it.
    The process is non-destructive on the dropped .app bundles, but just creates an entry in a separate registry.
    Apps can be individually "retinized" and de-retinized", or you can choose the global "retinize all apps" (on my Mac).
    As Applescripts use mostly (or completely?) standard UI elements this is an acceptable fix for now.
    @Apple:
    It is desirable that Apple's own software should support all its hardware features out-of-the-box.
    Please make AppleScript Editor compile retina compatible apps.
    (Maybe fixed in Yosemite? Confirmation anyone?)

Maybe you are looking for

  • I movie video editting. tutorials regarding enhancing movies

    This is driving me round the bend and "chat" tell me they cant offer suggestions??????.The turial regarding themes and polish reads: "To view the different themes available in iMovie, click Themes. Use the pop-up menu at the top of the Themes pane to

  • How to use JCo from IPC 5.0

    Hi, We just upgraded CRM from 4.0 to 5.0, and now I´m trying to do the necesary changes in the pricing formulas, but there´s one problem. With IPC 4.0 we could use JCo to make calls to R/3 4.6c to retrieve additional data (performance not an issue),

  • Gallery movies will not play.

    Hi, Using iLife '08, i have published some movies and pictures on my iPhoto gallery. All my friends and family can view the movies with no problems on their computers. If i try to view my gallery via Safari or another web browser i get a message that

  • How to read summary page in itunes

    Can someone please tell me on the summary page with iPhone pluged in, the bar on the bottom, what is 'OTHER'? Its taking a lot of space and if I could cut it down, that would be great. Thanks in advance.

  • All birthdays in September 1978 change back to 1! Any workaround?

    When I try to enter a contact's birthday, which is 16 September 1978, all days become grey and it changes back to 1 September 1978, as if that month only had 1 day. Any way to fix this?