Re: AppleScript Save as...
Thanks Christopher, I am copying and pasting found text tell application BBEdit activate find div class=\placeholder\ searching in text 1 of text document index.html options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match set theResult to balance tags set t to the text of selection as string set t to div id=\page_main\ return t /div set the clipboard to t end tell .. and in the second script... find (?s) This is the template for monthly sightings.*?Check in WYSIWYG mode and save again\\.br\\r searching in text 1 of text document Month 2013.htm options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false} with selecting match paste This works as expected. I realise that I could set a variable to the text of the selection but I'm still stuck in my old HyperCard ways ;?) On Saturday, November 1, 2014 4:56:44 PM UTC, jgill wrote: I'm using an AppleScript to generate a web page which needs to be saved to a specific local folder. I can't figure out how to access BBEdit's Save as... operation. Save is covered in the BBEdit Dictionary but not Save as... -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Re: AppleScript Save as...
On Nov 02, 2014, at 03:36, jgill joegillespie2...@gmail.com wrote: I am copying and pasting found text __ Hey Joe, A good rule of the thumb in automation is to never use the clipboard, unless it's the best tool for the job. It's a common failure-point and/or slow-down. This is roughly how I'd go about it. (I've also cleaned up certain aspects of my previous script.) --- set templateFile to alias ((path to home folder as text) test_directory:BBEdit_Test_Dir:Template.txt) set basePath to ((path to documents folder as text) (2014):) tell (current date) to set newFileName to (its month as text) its year .html set newFilePath to basePath newFileName tell application BBEdit open templateFile tell result to save to newFilePath tell text of text document newFileName set foundReco to find div class=\placeholder\ options ¬ {search mode:grep, starting at top:true, case sensitive:false} # I'm not seeing any benefit to this line; am I missing something? # set theResult to balance tags # == FALSE set replaceText to div id=\page_main\ return (contents of text of found object of foundReco) /div # Assuming the newly created document is the target. replace (?s) This is the template for monthly sightings.*?Check in WYSIWYG mode and save again\\.br\\r using replaceText ¬ options {search mode:grep, starting at top:true, case sensitive:false} end tell end tell --- -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Re: AppleScript Save as...
Christopher, the reason I am using copy and paste is that there are two separate (rather complicated) Applescripts involved here. One which selects text from one page and another that inserts that text into a placeholder. Short of using an intermediate window, I can't think of any way to transfer over 1000 lines of HTML from one window to another across scripts. I haven't tried to do it all in a single script because of timing issues. Using 'Balance Tags' seems to be a good way to select the contents of an entire div (with lots of nested divs). Thanks again for your help. Joe On Saturday, November 1, 2014 4:56:44 PM UTC, jgill wrote: I'm using an AppleScript to generate a web page which needs to be saved to a specific local folder. I can't figure out how to access BBEdit's Save as... operation. Save is covered in the BBEdit Dictionary but not Save as... -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Re: AppleScript Save as...
On Nov 02, 2014, at 07:59, jgill joegillespie2...@gmail.com wrote: Christopher, the reason I am using copy and paste is that there are two separate (rather complicated) Applescripts involved here. One which selects text from one page and another that inserts that text into a placeholder. __ Hey Joe, Without seeing the actual process I can't speculate too much, but in general it's quite easy to work between two windows in one script. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Re: AppleScript Save as...
Hi Cristopher, I managed to do it with one script. The timing issues I had with my old MacPro are not there with my new iMac. It's much faster. Can I ask how you manage to insert colour-coded scripts into this forum? Thanks, Joe On Saturday, November 1, 2014 4:56:44 PM UTC, jgill wrote: I'm using an AppleScript to generate a web page which needs to be saved to a specific local folder. I can't figure out how to access BBEdit's Save as... operation. Save is covered in the BBEdit Dictionary but not Save as... -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Re: AppleScript Save as...
On Nov 02, 2014, at 13:11, jgill joegillespie2...@gmail.com wrote: I managed to do it with one script. __ Hey Joe, Very good. Can I ask how you manage to insert colour-coded scripts into this forum? I copy them from Script Debugger (after compiling) and paste them into Mail (the Applescript Editor works similarly). Any source of styled-text should do. You can post styled-text from Gmail, and I'm fairly sure you can from the BBEdit Google-Groups page as well. If you're dealing with a shell script or other programming language in BBEdit you can use the 'Copy as Styled Text' item in BBEdit's Edit Menu. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
AppleScript Save as...
I'm using an AppleScript to generate a web page which needs to be saved to a specific local folder. I can't figure out how to access BBEdit's Save as... operation. Save is covered in the BBEdit Dictionary but not Save as... -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Re: AppleScript Save as...
On Nov 01, 2014, at 11:56, jgill joegillespie2...@gmail.com wrote: I'm using an AppleScript to generate a web page which needs to be saved to a specific local folder. I can't figure out how to access BBEdit's Save as... operation. __ Hey Joe, There's not a save-as command per se. Are you saving an unsaved document? Are you saving a previously saved document to a new location? What exactly are you doing? An unsaved document is easy to handle: -- set destFolderPath to path to downloads folder as text # HFS path. set newFileName to A Test File.html set savePath to destFolderPath newFileName tell application BBEdit tell front text document save to savePath end tell end tell -- If you're dealing with a previously saved file then the story is a bit different. Handling that improperly can cause you to lose data in the original file if it's unsaved. Here's one way to deal with that: -- set destFolderPath to POSIX path of (path to downloads folder as text) set newFileName to A Test File.html set savePath to quoted form of (destFolderPath newFileName) tell application BBEdit tell front text document if on disk = true then if modified of its window = true then save end if set _file to quoted form of (POSIX path of (get its file)) tell AppleScript do shell script cp _file savePath end tell end if end tell end tell -- I've used the shell, since I can copy and rename the file in one operation. If I wanted to be safer I could copy the file with the Finder and then rename it. The Finder will balk if there is an existing file. Or I could deliberately check to see if there's going to be a collision and throw an error. Or I could duplicate the document in BBEdit and use the first method to save it. It really depends upon what you need to be done. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Re: AppleScript Save as...
Thank you Christopher, The files is a template file which I modify with AppleScript. It has a default name Month Year.html. The AppleScript opens it, does a paste operation, and changes a few lines of text. I then want to save the modified files into another folder (2014) as, for instance November 2014.html. This changes from month to month appropriately. I could hard code the save path or generate it using the date object. So, it is a previously saved file but is being modified and saved to a different location. It will not be replacing the original template. Thanks, Joe On Saturday, November 1, 2014 4:56:44 PM UTC, jgill wrote: I'm using an AppleScript to generate a web page which needs to be saved to a specific local folder. I can't figure out how to access BBEdit's Save as... operation. Save is covered in the BBEdit Dictionary but not Save as... -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Re: AppleScript Save as...
On Nov 01, 2014, at 17:57, jgill joegillespie2...@gmail.com wrote: So, it is a previously saved file but is being modified and saved to a different location. It will not be replacing the original template. __ Hey Joe, Okay. Something like this should work. --- set _template to alias ((path to home folder as text) test_directory:BBEdit_Test_Dir:Template.txt) set basePath to ((path to documents folder as text) (2014):) tell (current date) set _month to its month as text set _year to its year end tell set newFileName to _month _year .html set newFilePath to basePath newFileName tell application BBEdit set newDoc to open _template tell newDoc to save to newFilePath tell document newFileName # Do your edits. # Save. end tell end tell --- Are you actually pasting into the newly opened template? If so there's probably a better way. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit --- You received this message because you are subscribed to the Google Groups BBEdit Talk group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com.
Applescript save window 1 behaves differently in BBEdit 9
I have a very simple script to simultaneously save the current BBEdit file and refresh Safari. tell application BBEdit save window 1 end tell tell application Safari do JavaScript document.location=document.location in document 1 end tell This script worked great in BBEdit 8, however it appears to not work in BBEdit 9. Instead of saving the current doc back to where ever it's opened from on the server, it brings up a save dialog to save the file locally. I know this should be easy, but it eludes me. And using the Record command in the Scripts menu is no help, as Save doesn't get recorded. Any help is greatly appreciated! -- 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+unsubscr...@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 supp...@barebones.com rather than posting to the group. Follow @bbedit on Twitter: http://www.twitter.com/bbedit