'フォルダ内のdatリストを作るwsh '2007.8/16  http://www.geocities.jp/mirrorhenkan/ 'リストはランダムになってしまうのでソートし直すようにしました 'バブルソートって難しい・・・。 '参考元: 'http://www.jfast.net/~saikawa/wsh/file.html#dir 'http://www1.u-netsurf.ne.jp/~tomo_c/tips/R23Lev03.html Set fs = WScript.CreateObject("Scripting.FileSystemObject") Set f = fs.getFolder(".") 'サブフォルダは使わないのでコメントアウト 'For Each temp In f.SubFolders ' s = s & temp.Name & vbCrLf 'Next For Each temp In f.Files FileEx = fs.GetExtensionName(temp) ' ファイル名から拡張子を抜き出す If LCase(FileEx) = "dat" Then ' 拡張子を小文字化してから比較 s = s & temp.Name & vbCrLf End If Next 'ここまでで代数sにdatのリストが入り、これをソート出来れば完成なんですが。 'WScript.Echo s Set abc = fs.CreateTextFile("datリスト.txt") abc.Write s abc.Close '////////datリストをソート//////// Dim datList() ReDim datList(0) If WScript.Arguments.Count>0 Then For Each arg In WScript.Arguments If fs.FileExists(arg) Then readfile arg End If Next Else If Fs.FileExists("datリスト.txt") Then readfile "datリスト.txt" End If If UBound(datList)=0 Then MsgBox "datリストに記載がありません!" wscript.quit Else Redim Preserve datList(UBound(datList)-1) End If Dim i 'ループカウンタ用変数 Do gyakuten=0 For i = 0 To UBound(datList)-1 Step 1 '0から最後まで、1ずつ変化させる 'wscript.echo datList(i) if datList(i)>datList(i+1) then temp=datList(i):datList(i)=datList(i+1):datList(i+1)=temp gyakuten=1 end if ''wscript.echo UBound(datList) ''wscript.quit Next 'UBound(datList) = UBound(datList)-1 Loop while gyakuten = 1 for i = 0 to UBound(datList) kekka = kekka & datList(i) & vbCrLf next Set abc = fs.CreateTextFile("datリスト.txt") abc.Write kekka abc.Close 'msgbox kekka,,"並べ替えた結果" msgbox "datリストを生成しました",,"終了" wscript.quit Sub readfile(path) Set ts=Fs.OpenTextFile(path,1) Do While ts.AtEndOfStream <> True tmp=ts.ReadLine tmp=Trim(tmp) If Len(tmp)<>0 Then datList(UBound(datList))=tmp Redim Preserve datList(UBound(datList)+1) End If Loop ts.Close End Sub