Hello everyone,
I have been browsing around for some solutions but I have not been that lucky. I have a set of folders that will moved every month to an archive folder for that respective month. Additionally, this archive folder will contain an HTML file that will display links to the set of folders that are moved. I want to be able to add the name of the folders to that file, and I have two possible scenarios:
1. I can use a template file and just replace a specific string throughout the file with the name of each individual folder.
This is the code I have for the 1st scenario:
2. I can create an entire HTML file and write the name of the folders in one specific location. Now, my problem with this scenario is that I have four DIV sections that will contain 8 links each section, but I don't know how to add 8 folders at a time.
I have been playing around with the Replace function, but I haven't been able to get it to work as I would like it to.
This is the code for the 2nd scenario:
I know that the
section writes the folders 8 times each. Also, this is the section that I would like to run in each individual DIV section if that has to be the case, but I only need it to every 8th folder to that section.
Any help or suggestions are welcomed.
Thanks in advance.
I have been browsing around for some solutions but I have not been that lucky. I have a set of folders that will moved every month to an archive folder for that respective month. Additionally, this archive folder will contain an HTML file that will display links to the set of folders that are moved. I want to be able to add the name of the folders to that file, and I have two possible scenarios:
1. I can use a template file and just replace a specific string throughout the file with the name of each individual folder.
This is the code I have for the 1st scenario:
Code:
Const ForReading = 1
Const ForWriting = 2
strArchive = "C:\Inetpub\[URL unfurl="true"]wwwroot\AWStats\archive\September"[/URL]
strText = "#FOLDER#"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strArchive)
Set objFile = objFSO.OpenTextFile("G:\September.htm", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If InStr(strLine, strText) Then
strNewContent = strNewContent & strLine
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("G:\September.htm", ForWriting)
For Each subf In objFolder.SubFolders
objFile.WriteLine Replace(strLine, "#FOLDER#", subf.Name)
Next
'strFolder = Replace("<a href=""./#FOLDER#/awstats.kinray.html"">", "#FOLDER#", strFolders)
'objFile.WriteLine strFolders
objFile.Close
I have been playing around with the Replace function, but I haven't been able to get it to work as I would like it to.
This is the code for the 2nd scenario:
Code:
strMonthName = Month(Date) - 1
strMonthName = MonthName(strMonthName, False)
strPath = "C:\Inetpub\[URL unfurl="true"]wwwroot\AWStats\archive\"[/URL] & strMonthName & "\"
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPath)
Set objHTML = objFSO.OpenTextFile(strPath & strMonthName & ".htm", ForWriting, True)
objHTML.WriteLine "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN""
""[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"[/URL]
objHTML.WriteLine "<html xmlns=""[URL unfurl="true"]http://www.w3.org/1999/xhtml""[/URL] >"
objHTML.WriteLine "<head>"
objHTML.WriteLine "<title>" & strMonthName & "Weblink Statistics</title>"
objHTML.WriteLine "<link href=""/css/month.css"" rel=""stylesheet"" type=""text/css"" />"
objHTML.WriteLine "</head>"
objHTML.WriteLine "<body>"
objHTML.WriteLine "<div class=""wrapper"">"
objHTML.WriteLine "<h2>" & strMonthName & "Weblink Statistics</h2>"
objHTML.WriteLine "<div id=""days"">"
objHTML.WriteLine "<div id=""week1"" class=""week"">"
objHTML.WriteLine "<h3 class=""heading"">Week 1</h3>"
objHTML.WriteLine "<ul>"
For Each folder In objFolder.SubFolders
For i = 1 To 8
objHTML.WriteLine "<li class=""date""><a href=""./" & folder.Name & "/awstats.kinray.html"">" & folder.Name & "</a></li>"
Next
Next
objHTML.WriteLine "</ul>"
objHTML.WriteLine "</div>"
objHTML.WriteLine "<div id=""week2"" class=""week"">"
objHTML.WriteLine "<h3 class=""heading"">Week 2</h3>"
objHTML.WriteLine "<ul>"
objHTML.WriteLine "</ul>"
objHTML.WriteLine "</div>"
objHTML.WriteLine "<div id=""week3"" class=""week"">"
objHTML.WriteLine "<h3 class=""heading"">Week 3</h3>"
objHTML.WriteLine "<ul>"
objHTML.WriteLine "</ul>"
objHTML.WriteLine "</div>"
objHTML.WriteLine "<div id=""week4"" class=""week"">"
objHTML.WriteLine "<h3 class=""heading"">Week 4</h3>"
objHTML.WriteLine "<ul>"
objHTML.WriteLine "</ul>"
objHTML.WriteLine "</div>"
objHTML.WriteLine "</div>"
objHTML.WriteLine "</div>"
objHTML.WriteLine "</body>"
objHTML.WriteLine "</html>"
objHTML.Close
I know that the
Code:
For i = 1 To 8
Any help or suggestions are welcomed.
Thanks in advance.