Sign in to follow this  
Followers 0
lordsocke

Read out URL from .txt

6 posts in this topic

Hi guys I want to copy out all links with a specific beginning from an textfile into another any ideas?

Share this post


Link to post
Share on other sites



Look at the following in the help file:

  • FileReadToArray(filename)
  • For..In Loop (For $element in $aArray) to loop through each line in the file
  • StringInStr - If StringInStr($element, "mytext") Then DoSomething.

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

the file is about 2mb any more "efficient" solutions?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I parsed a 3MB text file to an array in less than a second, exactly what level of efficiency are you looking to achieve?

Edited by JLogan3o13

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

okay maybe im just to noobie to understand it rigth could you explane it better? or give me an example?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Something like this? Finishes in just over a second for me on a 3MB file full of URLs.

#include <Array.au3>
#include <FileConstants.au3>

$sFile1 = FileOpen(@DesktopDir & "\1.txt", $FO_READ)
$sFile2 = FileOpen(@DesktopDir & "\2.txt", $FO_APPEND)

Local $aArray = FileReadToArray($sFile1)
    For $element in $aArray
        If StringInStr($element, "aslpro.com") Then FileWriteLine($sFile2, $element)
    Next

FileClose($sFile1)
FileClose($sFile2)
Edited by JLogan3o13

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0