Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Quickly generate hyperlinks from list of files or files in an HTML table?

Quickly generate hyperlinks from list of files or files in an HTML table?
Thread Tools
Forum Regular
Join Date: Oct 1999
Location: London
Status: Offline
Reply With Quote
Oct 8, 2007, 07:57 AM
 
I have an immense list of files captured in an Excel spreadsheet. I need to make a hyperlinked HTML file from this.

I can create a nice table, but I'm wondering if there's a search and replace routine that can help me build the links? I need to get this done quickly ...

Here's the unmodified table:

<table border="1" cellpadding="3" cellspacing="3">
<col width="162" />
<col width="174" />
<col width="161" />
<tr height="12">
<td width="162" height="12">croftfm32.1.1.tdxex</td>
<td width="174">croftfm32.1.1.tdxgs</td>
<td width="161">croftfm32.1.1.tdxsp</td>
</tr>
<tr height="12">
<td height="12">croftfm32.1.2a+b.tdxex</td>
<td>croftfm32.1.2a+b.tdxgs</td>
<td></td>
</tr>
<tr height="12">
<td height="12">croftfm32.1.3.tdxex</td>
<td>croftfm32.1.3.tdxgs</td>
<td></td>
</tr>
<tr height="12">
<td height="12">croftfm32.1.4.tdxex</td>
<td>croftfm32.1.4.tdxgs</td>
<td></td>
</tr>
<tr height="12">
<td height="12">croftfm32.1.5.tdxex</td>
<td>croftfm32.1.5.tdxgs</td>
<td></td>
</tr>
<tr height="12">
<td height="12">croftfm32.1.6.tdxex</td>
<td>croftfm32.1.6.tdxgs</td>
<td>croftfm32.1.6.tdxsp</td>
</tr>
<tr height="12">
<td height="12">croftfm32.2.1.tdxex</td>
<td>croftfm32.2.1.tdxgs</td>
<td></td>
</tr>
<tr height="12">
<td height="12">croftfm32.3.1a.tdxex</td>
<td>croftfm32.3.1a.tdxgs</td>
<td>croftfm32.3.1a.tdxsp</td>
</tr>
<tr height="12">
<td height="12">croftfm32.3.1b.tdxex</td>
<td>croftfm32.3.1b.tdxgs</td>
<td></td>
</tr>
<tr height="12">
<td height="12">croftfm32.3.1c.tdxex</td>
<td>croftfm32.3.1c.tdxgs</td>
<td></td>
</tr>
<tr height="12">
<td height="12">croftfm32.3.1d.tdxex</td>
<td>croftfm32.3.1d.tdxgs</td>
<td></td>
</tr>
<tr height="12">
<td height="12">croftfm32.3.1e.tdxex</td>
<td>croftfm32.3.1e.tdxgs</td>
<td></td>
</tr>
</table>

And here's what the first link should look like:

<a href="viewer.htm?tdxex=croftfm32.1.1.tdxex">croftf m32.1.1.tdxex</a>

Any help would be greatly appreciated - I have two hundred of these and I'd rather not cut and past filenames again and again!

Many thanks!
     
Senior User
Join Date: Dec 2002
Status: Offline
Reply With Quote
Oct 8, 2007, 03:47 PM
 
What you need is a regular expression search & replace. You can do that with TextWrangler. Just open your document with the table in TextWrangler, Search menu -> Find. Check the box that says Use Grep. In the top (search) box you'll enter the pattern you want to match. In the bottom (replace) box you enter the pattern to replace with.

You need to be a little more specific about how you want to generate the URLs, but from your example I am thinking you probably want to search for every <TD></TD> pair that has something in it, then take the extension and craft it into the url: <a href="viewer.htm?{EXTENSION}={FILENAME}.{EXTENSION }">{FILENAME}.{EXTENSION}</a>

If that's right try this:
Search for: <td.*>(.+)\.(.+)</td>
Replace with: <a href="viewer.htm?\2=\1.\2">\1.\2</a>
Travis Sanderson
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:33 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2