László Sándor how to script a multi-file search?
Sep 06, 2009; 15:10
László Sándor
how to script a multi-file search?
Hi all,I'm new to both BBEdit and AppleScript, so please forgive my ignorance. But let me also say that I spent the better half of my Sunday trying to resolve this issue, which also might say something about the documentation of BBEdit scripting (or implementation, or a bug).
I wanted to have a script that goes through all the links on a website and downloads the pdfs linked in. (FYI, download managers did not work, as the course websites at my university require authentication, and somehow only a browser could manage that. I'd be glad if, say, DownThemAll would quickly do the job in Firefox, but it cannot.)
I have the simple script below to ask for the URL, then grab the source, then look for the right pattern. I'm sort of proud having the right grep pattern to extract the links. Surprisingly, I could not figure out how to use the result coming from BBEdit. The user's manual is almost completely silent on the most complicated search-scripting issue (i.e. multi-file search), the AppleScript Editor under Snow Leopard cannot open the dictionaries of BBEdit or TextWrangler, but even now that Script Debugger could, I cannot parse how I could use result of a multi-file search (a bit of success/failure or a "search results browser" window ID). I could not use search results browser window to do any work.
Thank you for looking into this, any help would be greatly appreciated. I am aware of some messages from earlier this year when Jeff tried to do something similar, but apparently exchanged three emails with himself on this list without resolving the issue. Some clarification could benefit the whole community.
Thanks,
Laszlo
The script:
display dialog "What is the URL of the course readings site with the PDF links?" default answer "" set theURL to the text returned of the result tell application "WebKit" set the URL of the front document to theURL set theText to the source of front document end tell
-- set listOFlinks to {} tell application "BBEdit" make new document set text of front document to theText set fndResults to match list window of (find "(?<=href=\")((\\S*)(\\.pdf))|((\\S*)(harvard.edu)(\\S*))(?=\")" searching in front document options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}) -- get properties of fndResults -- get contents of fndResults get text of fndResults (* repeat with i from 1 to count of items in fndResults set this_item to result_file of item i of fndResults copy this_item to end of listOFlinks end repeat *) end tell
tell application "WebKit" repeat with i from 1 to count of items in listOFlinks set the URL of the front document to i save document 1 end repeat end tell
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/bbedit?hl=en If you have a feature request or would like to report a problem, please email "support@barebones.com" rather than posting to the group. -~----------~----~----~----~------~----~------~--~-
Sep 07
László Sándor Re: how to script a multi-file search?
Sep 07, 2009; 19:16
László Sándor
Re: how to script a multi-file search?
Sep 08
Jim Correia Re: how to script a multi-file search?
Sep 08, 2009; 08:33
Jim Correia
Re: how to script a multi-file search?
Sep 08
László Sándor Re: how to script a multi-file search?
Sep 08, 2009; 14:58
László Sándor
Re: how to script a multi-file search?
Sep 09
Jim Correia Re: how to script a multi-file search?
Sep 09, 2009; 06:38
Jim Correia
Re: how to script a multi-file search?
Sep 13
László Sándor Re: how to script a multi-file search?
Sep 13, 2009; 13:23
László Sándor
Re: how to script a multi-file search?
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!