フォルダ内にある全ファイル名取得
VBSでファイルを取得してMsgを表示する
Dim objFileSys
Dim objFolder
Dim objFile
Set objFileSys = CreateObject("Scripting.FileSystemObject")
'フォルダオブジェクトを取得
Set objFolder = objFileSys.GetFolder("ディレクトリ名")
'FolderオブジェクトのFilesプロパティからFileオブジェクトを取得
For Each objFile In objFolder.Files
'取得したファイルのファイル名を表示
WScript.Echo objFile.Name
Next
Set objFolder = Nothing
Set objFileSys = Nothing
↓こちらはtxtに出力する
Dim objFileSys
Dim objFolder
Dim objFile
Dim objOutputTextStream
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set objOutputTextStream = objFileSys.OpenTextFile("log.txt", 2, True)
'フォルダオブジェクトを取得
Set objFolder = objFileSys.GetFolder("ディレクトリ名")
'FolderオブジェクトのFilesプロパティからFileオブジェクトを取得
For Each objFile In objFolder.Files
'ファイル名を取得し、ログファイルに出力
objOutputTextStream.WriteLine objFile.Name
Next
'TextStream は Close を忘れずに
objOutputTextStream.Close
Set objOutputTextStream = Nothing
Set objFolder = Nothing
Set objFileSys = Nothing