hoge フォルダの中に
a.html
b.html
c.html
d.html
・
・
・
というようにテキストファイルがたくさん入っています
hogeの一つ上のフォルダに以下のテキストが入力されたhtmlファイルを作りたいのですがどのようなVBSを組めばいいでしょうか?教えてください
hoge.html
***************
http://hoge/a.html
http://hoge/b.html
http://hoge/c.html
http://hoge/d.html
http://hoge/・.html
http://hoge/・.html
http://hoge/・.html
***********
よろしくお願いします。
こんな感じになります。
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) For Each f In targetFolder.Files output.WriteLine "http://" & targetFolder.Name & "/" & f.Name Next output.Close
htmlファイルだけ表示したいのですがその場合どこいじればいいのでしょうか?
http://q.hatena.ne.jp/1417528810 の回答の方には IF 文を入れたのですが、以下のような判定を入れてください。
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) For Each f In targetFolder.Files If fs.GetExtensionName(f.Path) = "html" Then output.WriteLine "http://" & targetFolder.Name & "/" & f.Name End If Next output.Close
htmlファイルだけ表示したいのですがその場合どこいじればいいのでしょうか?
2014/12/03 00:24:54回答に追記しました。
2014/12/03 01:24:24