ライブラリ
ファイル一覧取得
'lFileListType)0:両方、1:ファイル、2:フォルダ、それ以外:格納しない
Function GetFileList( _
ByVal sTrgtDir, _
ByRef asFileList, _
ByVal lFileListType _
)
Dim objFileSys
Dim objFolder
Dim objSubFolder
Dim objFile
Dim bExecStore
Dim lLastIdx
Set objFileSys = WScript.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileSys.GetFolder( sTrgtDir )
'*** フォルダパス格納 ***
Select Case lFileListType
Case 0: bExecStore = True
Case 1: bExecStore = False
Case 2: bExecStore = True
Case Else: bExecStore = False
End Select
If bExecStore = True Then
lLastIdx = UBound( asFileList ) + 1
ReDim Preserve asFileList( lLastIdx )
asFileList( lLastIdx ) = objFolder
Else
'Do Nothing
End If
'フォルダ内のサブフォルダを列挙
'(サブフォルダがなければループ内は通らない)
For Each objSubFolder In objFolder.SubFolders
Call GetFileList( objSubFolder, asFileList, lFileListType)
Next
'*** ファイルパス格納 ***
For Each objFile In objFolder.Files
Select Case lFileListType
Case 0: bExecStore = True
Case 1: bExecStore = True
Case 2: bExecStore = False
Case Else: bExecStore = False
End Select
If bExecStore = True Then
'本スクリプトファイルは格納対象外
If objFile.Name = WScript.ScriptName Then
'Do Nothing
Else
lLastIdx = UBound( asFileList ) + 1
ReDim Preserve asFileList( lLastIdx )
asFileList( lLastIdx ) = objFile
End If
Else
'Do Nothing
End If
Next
Set objFolder = Nothing
Set objFileSys = Nothing
End Function
最終更新:2016年10月17日 22:24