Custom sequencing

160 views
Skip to first unread message

Maciek Schejbal

unread,
Dec 6, 2021, 10:32:53 AM12/6/21
to BBEdit Talk
Hullo BBEdits!

I have 250 images to be shown in the slide show. After I copy the paths, would anybody have a way to automate BBEdit to continue numbering the following sequence?

Many thanks,
Maciek

<figure>
<img src="images/eq/001.jpeg" width="100%" />
</figure>
<figure>
<img src="images/eq/002.jpeg" width="100%" />
</figure>

etc...

Arasmus

unread,
Dec 6, 2021, 2:57:59 PM12/6/21
to BBEdit Talk
Perhaps the easiest way would be to use a spreadsheet to generate the sequence of numbers from 1-250..paste the numbers into an empty text file..search and replace each of the numbers with the figure code.

Tom Robinson

unread,
Dec 6, 2021, 8:11:48 PM12/6/21
to bbe...@googlegroups.com
No need for a spreadsheet, BBEdit has a line numbering command :]

1. create document with 250 blank lines
2. Text > Add/Remove Line Numbers.  Don’t add spaces or justify — we just want a plain number
3. Do a Grep search for an entire line:
^.*$
Replace with the example HTML below verbatim, except substitute & for the 3 digits:
<figure>\n<img src="images/eq/&.jpeg" width="100%" />\n</figure>\n
4. profit

Christopher Stone

unread,
Dec 7, 2021, 2:33:05 AM12/7/21
to BBEdit-Talk
On Dec 06, 2021, at 09:31, Maciek Schejbal <your...@veryniceweb.com> wrote:
I have 250 images to be shown in the slide show. After I copy the paths, would anybody have a way to automate BBEdit to continue numbering the following sequence?


Hey Maciek,

Please provide an accurate sample of the before state of your copied paths.

Once we see that your task should be pretty simple.


--
Best Regards,
Chris


Arasmus

unread,
Dec 7, 2021, 2:31:12 PM12/7/21
to BBEdit Talk
Nice! I'd ssearched the manual for "sequence" before posting but missed the line numbers command. Thanks. 

Tim A

unread,
Dec 7, 2021, 9:31:59 PM12/7/21
to BBEdit Talk
Still are faced with adding 0 or 00 to numbers less than 100 of the generated line numbers, no? Or is there a buried preference for asserting the number of leading zeros?
Numbers.app allows this with the Cells/Data Format/Numeral System   Base and Places 


On Monday, December 6, 2021 at 5:11:48 PM UTC-8 Tom Robinson wrote:

Tom Robinson

unread,
Dec 7, 2021, 10:24:18 PM12/7/21
to bbe...@googlegroups.com
Right, that’s an issue.

You could search for a single digit and replace with 00<digit>, then do the same for double digits — or start at 1000 and remove the leading digit — but easier to use a spreadsheet :]

jj

unread,
Dec 8, 2021, 4:15:15 AM12/8/21
to BBEdit Talk
Execute this snippet of AppleScript with Script Editor:

    tell application "BBEdit"
        set vContents to ""
        repeat with i from 1 to 250
            set vNumber to i as string
            if i < 10 then
                set vNumber to "00" & vNumber
            else if i < 100 then
                set vNumber to "0" & vNumber
            end if
            set vContents to vContents & "<figure>\n<img src=\"images/eq/" & vNumber & ".jpeg\" width=\"100%\" />\n</figure>\n"
        end repeat
        make new document with properties {contents:vContents}
    end tell

HTH

Jean Jourdain

Christopher Waterman

unread,
Dec 8, 2021, 9:43:24 PM12/8/21
to BBEdit Talk
I've been trying to get better at awk recently and this seems like an awk kind of problem. 
Printing 3 digit numbers with leading zeros is definitely a problem printf is just sitting there waiting for.

Go Text • Run Unix Command and paste in paste in this command into the dialog:
seq 250 | awk '{printf "<figure>\n<img src=\"images/eq/%03d.jpeg\" width=\"100%%\" />\n</figure>\n", $0}'

On Monday, December 6, 2021 at 7:32:53 AM UTC-8 Maciek Schejbal wrote:

Maciek Schejbal

unread,
Dec 8, 2021, 10:14:53 PM12/8/21
to BBEdit Talk
Jean, 

Your script worked like a dream, many thanks!

And thank you all for participating.

Best,
Maciek 

Reply all
Reply to author
Forward
0 new messages