hoge フォルダの中に
a.html
b.html
c.html
d.html
・
・
・
というようにテキストファイルがたくさん入っています
hogeの一つ上のフォルダに以下のテキストが入力されたhtmlファイルを作りたいのですがどのようなVBSを組めばいいでしょうか?教えてください
hoge.html
***************
<tr><td>http://hoge/a.html</td><td>http://hoge/b.html</td></tr>
<tr><td>http://hoge/c.html</td><td>http://hoge/d.html</td></tr>
<tr><td>http://hoge/・.html</td><td>http://hoge/・.html</td></tr>
・
・
・
***********
こんな感じになります。
targetFolderName = "D:\test\hoge" ' ※ hoge フォルダのパス Set fs = WScript.CreateObject("Scripting.FileSystemObject") Set targetFolder = fs.getFolder(targetFolderName) Set parentFolder = targetFolder.ParentFolder Set output = fs.CreateTextFile(parentFolder.Path & "\list.html", True) output.WriteLine "<table>" For Each f In targetFolder.Files If fs.GetExtensionName(f.Path) = "html" Then output.WriteLine "<tr><td>http://" & targetFolder.Name & "/" & f.Name & "</td></tr>" End If Next output.WriteLine "</table>" output.Close
他で質問されていることも考慮して、以下の処理もしています。
左端 真ん中 右端で使っているタグは違います
失礼しました。2列の TABLE なんですね。
では、こんな感じでは、いかがでしょうか。
targetFolderName = "D:\test\hoge" ' ※ hoge フォルダのパス Set fs = WScript.CreateObject("Scripting.FileSystemObject") Set targetFolder = fs.getFolder(targetFolderName) Set parentFolder = targetFolder.ParentFolder Set output = fs.CreateTextFile(parentFolder.Path & "\list.html", True) output.WriteLine "<table>" odd = True For Each f In targetFolder.Files If fs.GetExtensionName(f.Path) = "html" Then If odd Then output.Write "<tr><td>http://" & targetFolder.Name & "/" & f.Name & "</td>" odd = False Else output.WriteLine "<td>http://" & targetFolder.Name & "/" & f.Name & "</td></tr>" odd = True End If End If Next output.WriteLine "</table>" output.Close
左端 真ん中 右端で使っているタグは違います
2014/12/03 01:35:42失礼しました。2列の TABLE なんですね。
2014/12/03 01:58:26修正したスクリプトを回答に追記しました。