Find/Select URL's within a txt file and parse to a new file?

Help with writing and playing macros

Find/Select URL's within a txt file and parse to a new file?

Postby SkyGaZeR » Sat Jan 29, 2005 8:02 pm

I have some large text files with paragraphs of text and usually a url after or within the paraghraph. How would I select just the url and parse it into a new internet shortcut file. Some of the url's are pretty long and may even contain search strings as in a google search or like that.
Thank you'
Sky 8)

So..If the url in the text Selected is
http://www.google.com/imghp?hl=en&tab=wi&q=

I want to save that as a .url file named "HOMEPAGE.URL"
The format of a .url file is as follows

[InternetShortcut]
URL=http://www.google.com/imghp?hl=en&tab=wi&q=
User avatar
SkyGaZeR
Newbie
 
Posts: 3
Joined: Mon Jan 24, 2005 12:00 am

Re: Find/Select URL's within a txt file and parse to a new f

Postby phealy » Mon Jan 31, 2005 12:04 pm

does a URL begin with HTTP and end with space (or EOL) If so do a wild card search, cut and paste the selection into a new file.

are multiple URL's in your original file? If so, not sure how you would name each file your building uniquely. The best I can think of is to process original file in a loop buiding each URL file as its own tab. When macro is done, let you manually exit out of UE letting it prompt you for a filename for each tab as you try to exit out of UE. Here is that macro. The macro assumes that when you start the macro there is only one tab in your UE session. THe macro assumes you will UNcheck the macro attribute "continue with find with replace not found" FYI: the macro begins by inserting a blank line at end of file. This so if last char of file is a URL it will terminate with a EOL instead of EOF.

If there is only one URL in your original text file you can get rid of the "loop" "endloop" and replace the "nextdocument" command with the commands
SaveAs "c:\HOMEPAGE.URL"
CloseFile


InsertMode
ColumnModeOff
HexOff
UnixReOff
Bottom
Key Ctrl+END
"
"
Top
Loop
Find RegExp "^{http*[ ]^}^{http*$^}"
StartSelect
Cut
NewFile
"[InternetShortcut]
"
Paste
NextDocument
EndLoop
User avatar
phealy
Newbie
 
Posts: 3
Joined: Tue Sep 07, 2004 11:00 pm


Return to Macros