Need help avioding 10000+ copy & pasting

Associate
Joined
31 Jul 2009
Posts
2,224
Location
127.0.0.1
EDIT: Can a mod please help me correct the 'avoiding' spelling mistake in the title. Thanks

Hi all, I am in the process of compiling an adblocker list for IE8. I already have all the addresses (from adblock firefox addon). The problem now is putting it all into xml form and thats it! (will share it once its done).

Heres the problem:

I have the list that contains all the addresses 5000+:

addresses.PNG



The addresses will then be put into this template individually, between the red highlighted characters:

template.PNG


Here is an example using the first 3 addresses (highlighted in green):

sample.PNG


As you can see, if i were to copy and paste all 5000+ addresses it would take for ever, not to mention possible mistakes. I also plan to update it monthly or even weekly. So is there any method i can use (program or anything) that can make the process faster?
Thx in advance:D
 
Last edited:
I created this using Powershell:

Code:
Get-Content input.txt | foreach { $_ = $_.trim(); $_ } | foreach { 
$_ = @"
<item>
    <description>$_</description>
    <wf:blockRegex>
        <![CDATA[$_]]>
    </wf:blockRegex>
<item>
"@; $_ } | foreach { Add-Content output.txt $_ }

Paste that into a text file and call it whatever.ps1. You will need to change the file names to suit your needs. Make sure you delete/rename the previous output file before you run the script again or it will append it all again to the end!

NB: To run powershell scripts you will need to open Powershell as Admin and enter:

Code:
Set-ExecutionPolicy "Unrestricted"
Say yes to the confirmation.

To run the script you can right-click it and click Open with.. and browse for Powershell. Or you can open a Powershell prompt and type

Code:
cd C:\path\to\script\folder
<enter>
.\whatever.ps1
 
Oh and just to be sure about something; Will the 'input.txt' be the name of the file containing all the addresses? And will the 'output.txt' be a blank file that gets filled when I run the script?
 
Yes. The input text will be that adblock.ini file in your first screenie. Output.txt will be created automatically if it doesn't already exist.

I would put the script in the same folder as your files, as in its current form it looks in the folder it is running from. You can also just put the full path C:\Users\temi_d\stuff\adblock.ini for example, then it wouldnt matter where you ran the script from. Same applies to the output file.
 
Back
Top Bottom