New To Applescript - Can This be done.

Hi All,

I’m a recent switcher have a mac mini and love it, I am trying to see if the following can be done and if it can if I can be pointed in the right direction.

I have a sports fan site where I wish to update section of HTTML from an excel produced webpage into my website template. it will need to copy a selction of code from excel html file (same postions each time) lets for example say lines 50-80 and then place in the webpage to replace the previous lines 10-40 (once again same positions each time).

It would be brilliant if this could be done i am using dreamweaver or bbedit 8.2

All help appreciated

Paul Raymond

Model: Mac Mini 1.42
Browser: Firefox 1.0.4
Operating System: Mac OS X (10.4)

You can adaptate this:

set fileA to read alias "path:to:fileA.html"
set fileB to read alias "path:to:fileB.html"

--> pick chunk from fileA
set chunk to paragraphs 50 thru 80 of fileA

--> join data, replacing relevant paragraphs
set AppleScript's text item delimiters to return
set newPage to (paragraphs 1 thru 10 of fileB & chunk & paragraphs 41 thru -1 of fileB) as text
set AppleScript's text item delimiters to {""}

--> write results to fileB
set fref to (open for access alias "path:to:fileB.html" with write permission)
set eof of fref to 0 --> empty file before writing
write newPage to fref
close access fref

If you are interested, take a look to our FAQ section, where you can find lots of ready-to-go answers:
http://www.macscripter.net/faq/
You can also use the “Search” button in this forum, which some times is absolutely useful.

  • As a general rule, try to use a more descriptive title for your questions, that is the only way you will get the folks at this BBS reading your topic :wink: