' "Contig.vbs" ' "Contig_dir.bat","Contig_file.bat"をContig.exeと同一ディレクトリに置く。 Set WshShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set arg = WScript.Arguments If arg.length<>0 Then fpath = arg(0) If fso.FileExists(fpath) Then bat = "<Contig_Dir_Path>\Contig_file.bat " Else bat = "<Contig_Dir_Path>\Contig_dir.bat " End If WshShell.Run bat & """" & fpath & """" End If
' ※<Contig_Dir_Path>←Contig.exeのディレクトリパス※ ---------------------------------------------------- @echo off rem "Contig_dir.bat" rem ドライブ 又は ディレクトリ を Contig -s (サブディレクトリを含) echo Contig -q -s %1\* cd /d <Contig_Dir_Path> cmd /k Contig.exe -q -s %1\* echo. ---------------------------------------------------- @echo off rem "Contig_file.bat" rem 単一ファイル を Contig -v (詳細表示) echo Contig -v %1 cd /d <Contig_Dir_Path> cmd /k Contig.exe -v %1 echo.
Set args = WScript.Arguments Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set listfile = Fs.CreateTextFile("list.txt",True) path = args(0) If Fs.FolderExists(path) Then Call RecursibleSearch(path) Else MsgBox "このパスは実在しません。" WScript.Quit End If listfile.close MsgBox "Finished creating list.txt" Sub RecursibleSearch(folderspec) Set fol = Fs.GetFolder(folderspec) Set flc = fol.Files For Each fl1 in flc If fl1.Size<67108864 Then listfile.WriteLine fl1.Path End If Next Set sfc = fol.SubFolders For Each sf1 in sfc Call RecursibleSearch(sf1.Path) Next End Sub
Set args = WScript.Arguments 'パラメータ取得のための準備 Set Fs = WScript.CreateObject("Scripting.FileSystemObject") 'Fsにファイルシステムオブジェクトを代入 Set listfile = Fs.CreateTextFile("list.txt",True) '結果を出力するためのテキストファイルを作成 path = args(0) 'パラメータを取得し、pathに格納 If Fs.FolderExists(path) Then 'もしもpathにフォルダーが存在するならば Call RecursibleSearch(path) '検索機能を呼び出し Else 'pathにフォルダーが存在しないならば MsgBox "このパスは実在しません。" 'メッセージを表示して WScript.Quit '終了 End If '(フォルダーの存在確認終了) listfile.close 'ファイルハンドルlistfileを閉じる MsgBox "Finished creating list.txt" '終了メッセージ Sub RecursibleSearch(folderspec) '検索機能の定義 Set fol = Fs.GetFolder(folderspec) 'フォルダーを取得し、folに代入 Set flc = fol.Files 'フォルダー内のファイル群を取得 For Each fl1 in flc 'ファイル群のそれぞれのファイルについて If fl1.Size<67108864 Then 'サイズが64MB未満ならば listfile.WriteLine fl1.Path 'ファイルのパスをlistfileに書き出し End If '(ファイル群処理の終了) Next '(次のファイルへ) Set sfc = fol.SubFolders 'フォルダー内の下位フォルダー群を取得 For Each sf1 in sfc '下位フォルダー群のそれぞれについて Call RecursibleSearch(sf1.Path) '検索機能を再帰呼び出し Next '(下位フォルダー群処理の終了) End Sub '(検索機能の定義の終了)
Summary: Number of files processed : 22722 Number of files defragmented: 2 Average fragmentation before: 1.00066 frags/file Average fragmentation after : 1 frags/file