Forum Moderators: phranque

Message Too Old, No Replies

Need a tool that creates text files from keyword list

         

ogletree

3:34 am on Nov 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I need a tool that will create a bunch of .html files from my keyword list. I don't want it to create the content just create the files. For each line in my keyword text field it would create a .html file. IE. It sees "keyword phrase" and creates an empty text file nameed "keyword-phrase.html.

ytswy

10:59 am on Nov 14, 2003 (gmt 0)

10+ Year Member



Assuming you are doing this locally, I would just use Excel and do a simple Macro.

I would assume the file is one keyword phrase per line, if so it ought to just import into Excel with each keyword phrase on its own line - in A1, A2, A3 etc.

If so just use a Macro like this:

Sub MakeFiles()
Const Path$ = "C:\relevant\directory\"
Dim FileName As String

Range("A1").Select
While Not IsEmpty(ActiveCell.Value)
FileName = ActiveCell.Value
Open Path$ + FileName + ".html" For Output As 1
Close 1
ActiveCell.Offset(1, 0).Range("A1").Select
Wend
End Sub

I use something similar, but I haven't actually tested this version so no warranty given or implied :)

It won't add any hyphens or anything, although it wouldn't be hard to make it do so (make a function that parses each FileName and replaces spaces with hyphens).

denisdekat

1:38 pm on Nov 14, 2003 (gmt 0)

10+ Year Member



Look here maybe [hotscripts.com...] [sourceforge.net...]

ogletree

2:13 pm on Nov 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That is just too cool. I made a few changes.

Sub MakeFiles()
Const Path$ = "C:\directory\"
Dim FileName As String

Range("A1").Select
While Not IsEmpty(ActiveCell.Value)
FileName = Replace(ActiveCell.Value, Chr$(32), "-", 1)
Open Path$ + FileName + ".html" For Output As 1
Print #1, "Text"
Print #1, "<br>"
Print #1,
Print #1, "Text2"
Close 1
ActiveCell.Offset(1, 0).Range("A1").Select
Wend
End Sub

[edited by: oilman at 9:28 pm (utc) on Nov. 14, 2003]

ytswy

3:52 pm on Nov 14, 2003 (gmt 0)

10+ Year Member



Glad you liked it :) I use Excel macros to make a kind of poor mans dynamic website - mergeing text from a stock list into a Dreamweaver template and saving the result as a page.

Wish I'd known there was a Replace function though... memo to self: RTFM

ogletree

8:55 pm on Nov 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have an Access programer that showed me. Good ole VB script.