'文字列を取得 Dim iText: iText = inputbox("絞り込みキーワードがあれば入力してください") Dim fso: set fso = createObject("Scripting.FileSystemObject") Dim txtPath : txtPath = fso.getParentFolderName(WScript.ScriptFullName) 'ここのフォルダパス Dim yPos : yPos = InStrRev(txtPath, "\") Dim tarPath : tarPath = Left(txtPath, yPos ) '対象フォルダパス Dim txtFulName: txtFulName = txtPath & "\" & "Dirリスト.txt" if iText <> "" then 'デフォは上記だけど、別指定したら変更する tarPath = tarPath & "*" & iText & "*" txtFulName = txtPath & "\" & "Dirリスト("& iText &").txt" end if Dim sCmd : sCmd = "Dir /S /A-D """ & tarPath & """ > """ & txtFulName & """ " &chr(10) 'ファイルとDir 指定できてない With CreateObject("WScript.Shell").Exec("clip") Call .StdIn.Write(sCmd) End With msgbox "クリップボードに出力しました。" & chr(10) & chr(10) & "<出力コマンド>" & chr(10) & sCmd