Hello, ive put together a script that searches textwrangler for an entry and searches the network disk for a template. I would like to make it now so when i start the script it will ask what i would like to do giving me 3 buttons: Search Job Numbers, Search Templates, and cancel. when i select the Search job numbers button i want the textwrangler script to come up. When its finished searching for the value i would like it to go back to the beginning with the 3 buttons. I would like the same thing to happen when I do the Search Templates button, but after i select the file that it has done the search for.
Here is the Textwrangler script:
tell application "TextWrangler"
activate
set jobNumber to text returned of (display dialog "Please enter the job number:" default answer "")
find jobNumber searching in {alias "Tin:Text from PICK:"} options {search mode:grep, case sensitive:false, match words:false, extend selection:false, showing results:true}
end tell
Here is the template search script:
set theFolder to {alias "Tin:Job Templates"}
set theFolderPP to POSIX path of theFolder
set {text returned:theFilenamePattern} to display dialog "Enter a template to search for (Put * after template number to list all):" with title "Template Search " & theFolderPP default answer ""
if length of theFolderPP is greater than 1 and theFolderPP ends with "/" then set theFolderPP to text 1 through -2 of theFolderPP
set findCmd to "find " & quoted form of theFolderPP & " -iname " & quoted form of theFilenamePattern & " -print;true"
set findResults to do shell script findCmd
set theMatches to paragraphs of findResults
set chosenPaths to choose from list theMatches with prompt "Matching Items: " & length of theMatches with empty selection allowed and multiple selections allowed
if chosenPaths is not equal to false and length of chosenPaths is greater than 0 then
set chosenFiles to {}
repeat with f in chosenPaths
try
set end of chosenFiles to alias POSIX file (contents of f)
end try
end repeat
if length of chosenFiles is greater than 0 then ¬
tell application "Finder"
activate
open chosenFiles
-- reveal chosenFiles
end tell
end if
Any help would be greatly appreciated!
Going Postal is online now Report Post Reply With Quote