Copy and replace

General discussions about Advanced Find and Replace
Post Reply
Gerna1964
Posts: 3
Joined: Sat Oct 06, 2007 9:25 am

Copy and replace

Post by Gerna1964 »

Hi,

I have over a hundred HTML files with a unique JPG picture name in it. Want I want is to copy the JPG file name and replace with a new code .

Example:

File name HTML file: N_art_13.html (or N_art_256.html)

Source:
<IMG SRC="b_13.jpg" ALT="Artikel 111" BORDER="0">

Replace into:
<a rel="lightbox" href="b_13.jpg">
<img src="b_13.jpg" width="300" height="261" class="style11"></a>

Number in filename (13) is the same as in d the code.

I hope that you can help me.

Thanks in advance,
Geert

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Re: Copy and replace

Post by Abacre »

Go to main menu - Action - Options - Batch Replace
check "Include File Name into Search Scope"
check "Modifier S"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
N_art_(\d+).html\r\n(.*)<IMG SRC="b_\1.jpg" ALT=".*" BORDER="0">

Replace with:
\r\n$2<a rel="lightbox" href="b_$1.jpg">\r\n<img src="b_$1.jpg" width="300" height="261" class="style11"></a>

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Gerna1964
Posts: 3
Joined: Sat Oct 06, 2007 9:25 am

Re: Copy and replace

Post by Gerna1964 »

Roman,

Thank you very much.

Time to purchase the software :D

Regards,
Geert Gernaat
Netherlands

Gerna1964
Posts: 3
Joined: Sat Oct 06, 2007 9:25 am

Re: Copy and replace

Post by Gerna1964 »

Hi Roman,

There is something strange with AFR or on my computer.

If I past your code into AFR and execute the program with regular expressions AFR can't find any HTML document.

But if a open the file(s) in a HTML editor or notepad and save the document without any changes, at that moment AFR find the string and replace it with the correct code???

Do you have any idea hiw this is possible.

Regards,
Geert

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Re: Copy and replace

Post by Abacre »

It's not clear what do you mean. Could you please explain it again?

Other programs may exclusively use your file without giving right to AFR (or other programs) to use it. So you should normally close other programs using the file before using AFR on the files.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Post Reply