Re: Automating HTML in BBedit with AppleScript

2012-04-01 Thread blinde
rather than script this, here's what i would do... old school, but quick 
and dirty:

1. drag the folder of original images onto an open/empty bbedit window. 
this will give you a list of all the images, no matter how many there are.

2. select all (command + a)

3. slam everything to the left (command + [ as many times as it takes)

4. run this saved grep pattern:

FIND: ^Photo(.+)orig\.jpg/string\\r
REPLACE: lt;a href=images_big/Photo\1orig.jpggt;lt;img 
src=images_thumbs/Photo\1prev.jpggt;lt;/agt;\\r

5. sorry that took so long!

i have a collection of saved grep patterns i use all the time... big time 
saver.

bruce








On Wednesday, March 28, 2012 2:21:59 AM UTC-7, blue-orange wrote:

 Hello, 

 I have the following task of creating a page with 1000 thumbnails 
 linked to larger files. 
 I want to automate the task and the automation part is an unfamiliar 
 territory for me. 

 I have two txt files containing 1000 thumbnail and original image 
 filenames that look like this: 

 original.txt: 
 Photo_19001_2010-11-18_13.45.59_orig.jpg 
 Photo_19002_2010-11-18_21.07.04_orig.jpg 
 Photo_19003_2010-11-19_10.48.19_orig.jpg 
 Photo_19004_2010-11-19_14.05.01_orig.jpg 
 Photo_19005_2010-11-19_14.05.05_orig.jpg 
 ... 

 preview.txt: 
 Photo_19001_2010-11-18_13.45.59_prev.jpg 
 Photo_19002_2010-11-18_21.07.04_prev.jpg 
 Photo_19003_2010-11-19_10.48.19_prev.jpg 
 Photo_19004_2010-11-19_14.05.01_prev.jpg 
 Photo_19005_2010-11-19_14.05.05_prev.jpg 
 ... 

 I have a HTML template: 
 a href=urlOriginalimg src=urlPreview/a 

 I want to replace the urlOriginal and urlPreview with the proper info 
 from the txt files. Repeat 999 times. 

 I understand this is not possible with BBEdit. 
 AppleScript to the rescue? 

 Where do I start? 


-- 
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


Re: Automating HTML in BBedit with AppleScript

2012-04-01 Thread blinde
sorry - the replace string should be:

a href=images_big/Photo\1orig.jpgimg src=images_thumbs/Photo
\1prev.jpg/a\r

no html entities, and a line return at the end

not sure how html shows up in these posts... we'll see in a minute!







On Mar 31, 6:13 pm, blinde bruce.li...@gmail.com wrote:
 rather than script this, here's what i would do... old school, but quick
 and dirty:

 1. drag the folder of original images onto an open/empty bbedit window.
 this will give you a list of all the images, no matter how many there are.

 2. select all (command + a)

 3. slam everything to the left (command + [ as many times as it takes)

 4. run this saved grep pattern:

 FIND: ^Photo(.+)orig\.jpg/string\\r
 REPLACE: lt;a href=images_big/Photo\1orig.jpggt;lt;img
 src=images_thumbs/Photo\1prev.jpggt;lt;/agt;\\r

 5. sorry that took so long!

 i have a collection of saved grep patterns i use all the time... big time
 saver.

 bruce







 On Wednesday, March 28, 2012 2:21:59 AM UTC-7, blue-orange wrote:

  Hello,

  I have the following task of creating a page with 1000 thumbnails
  linked to larger files.
  I want to automate the task and the automation part is an unfamiliar
  territory for me.

  I have two txt files containing 1000 thumbnail and original image
  filenames that look like this:

  original.txt:
  Photo_19001_2010-11-18_13.45.59_orig.jpg
  Photo_19002_2010-11-18_21.07.04_orig.jpg
  Photo_19003_2010-11-19_10.48.19_orig.jpg
  Photo_19004_2010-11-19_14.05.01_orig.jpg
  Photo_19005_2010-11-19_14.05.05_orig.jpg
  ...

  preview.txt:
  Photo_19001_2010-11-18_13.45.59_prev.jpg
  Photo_19002_2010-11-18_21.07.04_prev.jpg
  Photo_19003_2010-11-19_10.48.19_prev.jpg
  Photo_19004_2010-11-19_14.05.01_prev.jpg
  Photo_19005_2010-11-19_14.05.05_prev.jpg
  ...

  I have a HTML template:
  a href=urlOriginalimg src=urlPreview/a

  I want to replace the urlOriginal and urlPreview with the proper info
  from the txt files. Repeat 999 times.

  I understand this is not possible with BBEdit.
  AppleScript to the rescue?

  Where do I start?

-- 
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


Automating HTML in BBedit with AppleScript

2012-03-28 Thread blue-orange
Hello,

I have the following task of creating a page with 1000 thumbnails
linked to larger files.
I want to automate the task and the automation part is an unfamiliar
territory for me.

I have two txt files containing 1000 thumbnail and original image
filenames that look like this:

original.txt:
Photo_19001_2010-11-18_13.45.59_orig.jpg
Photo_19002_2010-11-18_21.07.04_orig.jpg
Photo_19003_2010-11-19_10.48.19_orig.jpg
Photo_19004_2010-11-19_14.05.01_orig.jpg
Photo_19005_2010-11-19_14.05.05_orig.jpg
...

preview.txt:
Photo_19001_2010-11-18_13.45.59_prev.jpg
Photo_19002_2010-11-18_21.07.04_prev.jpg
Photo_19003_2010-11-19_10.48.19_prev.jpg
Photo_19004_2010-11-19_14.05.01_prev.jpg
Photo_19005_2010-11-19_14.05.05_prev.jpg
...

I have a HTML template:
a href=urlOriginalimg src=urlPreview/a

I want to replace the urlOriginal and urlPreview with the proper info
from the txt files. Repeat 999 times.

I understand this is not possible with BBEdit.
AppleScript to the rescue?

Where do I start?

-- 
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


Re: Automating HTML in BBedit with AppleScript

2012-03-28 Thread TJ Luoma
On Wed, Mar 28, 2012 at 5:21 AM, blue-orange goo...@etculli.com wrote:
 I have two txt files containing 1000 thumbnail and original image
 filenames that look like this:

 original.txt:
 Photo_19001_2010-11-18_13.45.59_orig.jpg
 Photo_19002_2010-11-18_21.07.04_orig.jpg
 Photo_19003_2010-11-19_10.48.19_orig.jpg
 Photo_19004_2010-11-19_14.05.01_orig.jpg
 Photo_19005_2010-11-19_14.05.05_orig.jpg
 ...

 preview.txt:
 Photo_19001_2010-11-18_13.45.59_prev.jpg
 Photo_19002_2010-11-18_21.07.04_prev.jpg
 Photo_19003_2010-11-19_10.48.19_prev.jpg
 Photo_19004_2010-11-19_14.05.01_prev.jpg
 Photo_19005_2010-11-19_14.05.05_prev.jpg




Assuming that :

1. all of the filenames are exactly the same except that _orig.jpg
changes to _prev.jpg
2. the file 'original.txt' has one filename per line

then you can use a small shell script to do this:

#!/bin/sh

while read line
do

PREV=`echo $line | sed 's#_orig.jpg#_prev.jpg#g'`

echo a href=\$line\img src=\$PREV\/a

done  original.txt

I put this script up at
http://dl.dropbox.com/u/18414/tmp/bbedit3282012.sh if you want to
download it.

Save it to the same directory as 'original.txt'. Assuming they are
both on ~/Desktop/ then you would open Terminal.app and do

cd ~/Desktop/

chmod 755 ./bbedit3282012.sh

./bbedit3282012.sh

or, if you want to save the output of `bbedit3282012.sh`, then do

./bbedit3282012.sh  out.html

and then the file out.html will have the HTML that you need.

TjL

ps - I really can't help but mention that you should include WIDTH and
HEIGHT on the IMG tags. Otherwise the page is going to jump all over
the place as those 1,000 images load!! I assume you just left them off
your example to reduce visual clutter.

-- 
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


Re: Automating HTML in BBedit with AppleScript

2012-03-28 Thread Christopher Stone
On Mar 28, 2012, at 04:21, blue-orange wrote:
 I have the following task of creating a page with 1000 thumbnails linked to 
 larger files.
 I want to automate the task and the automation part is an unfamiliar 
 territory for me.

__

Hey There,

TJ's shell script looks quite spiffy, but this is maybe a little more 
user-friendly.

The script expects open documents for your original and preview lists:

 Original_Images.txt
 Preview_Images.txt

It will then assemble the requisite pieces into a new document.

On my MacBook Pro it takes ~ 0.5 seconds to run from the BBEdit Script Menu 
using 1000 line image lists.

Let me know whether or not that's what you had in mind.

--
Best Regards,
Chris


#   Author: Christopher C. Stone listmeis...@thestoneforge.com
#  Created: 2012-03-28 : 15:23
# Modified: 2012-03-28 : 15:23 
#  Application: BBEdit
#  Purpose: TEST FOR BLUE-ORANGE ON THE BBEDIT LIST.
# : Create href list from template and original  preview image url 
lists.
# Dependencies: none

try
set previewDocName to Preview_Images.txt
set originalDocName to Original_Images.txt
set hrefTemplateOrig to a href=\
set hrefTemplatePrev to \img src=\
set hrefTemplateEnd to \/a
set newDocContent to {}

tell application BBEdit
if (document originalDocName exists) and (document 
previewDocName exists) then
set prevEndLine to endLine of text of document 
previewDocName
set origEndLine to endLine of text of document 
originalDocName
if prevEndLine = origEndLine then
set prevLines to contents of lines of document 
previewDocName
set origLines to contents of lines of document 
originalDocName

repeat with i from 1 to length of prevLines
set _temp to hrefTemplateOrig  (item i 
of origLines)  hrefTemplatePrev  (item i of prevLines)  hrefTemplateEnd
set end of newDocContent to _temp
end repeat

set {oldTIDS, AppleScript's text item 
delimiters} to {AppleScript's text item delimiters, return}
set newDocContent to newDocContent as text
make new text document with properties 
{text:newDocContent}
set AppleScript's text item delimiters to 
oldTIDS

end if
end if
end tell

on error eMsg number eNum
set {c, s} to {return, --}
set e to s  c  Error:   eMsg  c  s  c  Error Number:   eNum 
 c  s
beep
display dialog e
end try


-- 
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