フォルダを整理するのはとてもたいへんな作業なので、まずは容量で優先順位を決めましょう▼ JScript のダウンロード
▼ VBScript のダウンロード
✅ スクリプト実行✅ 結果
System Volume Information は、無駄に使われてる場合が多いそうです。 ✅ 参考ページ ✅ System Volume Information をエクスプローラで表示させる
✅ データを削除
![]()
show-folders-size.js
// ************************************************
// カンマ編集
// ************************************************
String.prototype.number_format =
function (prefix) {
var num = this.valueOf();
prefix = prefix || '';
num += '';
var splitStr = num.split('.');
var splitLeft = splitStr[0];
var splitRight = splitStr.length > 1 ? '.' + splitStr[1] : '';
var regx = /(\d+)(\d{3})/;
while (regx.test(splitLeft)) {
splitLeft = splitLeft.replace(regx, '$1' + ',' + '$2');
}
return prefix + splitLeft + splitRight;
}
// ************************************************
// オブジェクト
// ************************************************
var Shell = new ActiveXObject("Shell.Application");
var WshShell = new ActiveXObject("WScript.Shell");
var Fso = new ActiveXObject( "Scripting.FileSystemObject" );
// ************************************************
// 管理者権限のコマンドプロンプトで再実行
// ************************************************
if ( WScript.Arguments.length == 0 ) {
Shell.ShellExecute( "cmd.exe", "/c cscript.exe " + Dd(WScript.ScriptFullName) + " next" + " & pause", "", "runas", 1 );
WScript.Quit();
}
var target = SelectDir( "対象フォルダを選択して下さい" )
if ( target == "" ) {
WScript.Quit();
}
WScript.Echo( target )
// ************************************************
// フォルダオブジェクト取得
// ************************************************
var objFolder = Fso.GetFolder(target)
var folderCollection = new Enumerator(objFolder.SubFolders);
var TargetSize = 0;
var obj;
var num;
var line;
for ( ;!folderCollection.atEnd(); folderCollection.moveNext()) {
obj = folderCollection.item();
try {
num = Math.floor(obj.Size / 1024) / 1024;
num = Math.floor( num * 1000 ) / 1000
line = Lpad(("" + num).number_format()," ", 15) + " M : " + obj.Name
WScript.Echo( line );
// フォルダ全体の合計
TargetSize = TargetSize + obj.Size
}
catch(e) {
WScript.Echo( obj.Name + " : 処理できません");
}
}
WScript.Echo( "" );
num = Math.floor(TargetSize / 1024) / 1024;
num = Math.floor( num * 1000 ) / 1000
line = Lpad(("" + num).number_format()," ", 15) + " M : " + "表示合計"
WScript.Echo( line );
// ************************************************
// ディレクトリ選択
// ************************************************
function SelectDir( strTitle ) {
var obj
obj = Shell.BrowseForFolder( 0, strTitle, 0x4B, 0 )
if ( obj == null ) {
return "";
}
if ( !obj.Self.IsFileSystem ) {
ErrorMessage = "ファイルシステムではありません";
return "";
}
return obj.Self.Path;
}
// ************************************************
// ダブルクォートで囲む
// ************************************************
function Dd( strValue ) {
return "\"" + strValue + "\""
}
// ************************************************
// 指定数、指定文字列左側を埋める
// ※少数以下3桁の調整
// ************************************************
function Lpad( strValue, str, nLen ) {
var i;
var wk = "";
for( i = 0; i < nLen; i++ ) {
wk += str;
}
var test = strValue.split(".");
if ( test.length == 2 ) {
if ( test[1].length == 0 ) {
strValue += "000"
}
if ( test[1].length == 1 ) {
strValue += "00"
}
if ( test[1].length == 2 ) {
strValue += "0"
}
}
else {
strValue += ".000"
}
return ( wk + strValue ).slice( nLen * -1 );
}
show-folders-size.vbs
' ************************************************ ' 管理者権限で実行用 ' ************************************************ Set Shell = CreateObject( "Shell.Application" ) ' ************************************************ ' 管理者権限で再実行 ' ************************************************ if Wscript.Arguments.Count = 0 then Shell.ShellExecute "cmd.exe", "/c cscript.exe " & Dd(WScript.ScriptFullName) & " next" & " & pause", "", "runas", 1 Wscript.Quit end if ' ************************************************ ' 除外フォルダ名を スペースで区切って並べる ' (簡易的な除外) ' ************************************************ Dim Exclude Exclude = ".gem" Exclude = Lcase(Exclude) ' ************************************************ ' 処理用 ' ************************************************ Set WshShell = CreateObject( "WScript.Shell" ) Set Fso = CreateObject( "Scripting.FileSystemObject" ) Dim target ' ************************************************ ' 対象フォルダを選択 ' ************************************************ target = SelectDir( "対象フォルダを選択して下さい" ) if target = "" then Wscript.Quit end if Wscript.Echo target Wscript.Echo ' ************************************************ ' フォルダオブジェクト取得 ' ************************************************ Set objFolder = Fso.GetFolder(target) ' ************************************************ ' サブフォルダコレクション取得 ' ************************************************ Set colSubFolder = objFolder.SubFolders ' ************************************************ ' 一覧 ' ************************************************ Dim TargetSize : TargetSize = 0 For Each obj in colSubFolder Do While true if InStr(Exclude,Lcase(obj.Name)) > 0 then Exit Do end if on error resume next Wscript.Echo Lpad(FormatNumber((Fix(obj.Size / 1024) / 1024),3)," ", 15) & " M : " & obj.Name if Err.Number <> 0 then Wscript.Echo " ( " & obj.Name & " : 処理できません )" else TargetSize = TargetSize + obj.Size end if on error goto 0 Exit Do Loop Next Wscript.Echo Dim AllSize Dim er : er = 0 on error resume next AllSize = objFolder.Size if Err.Number <> 0 then er = 1 AllSize = TargetSize end if on error goto 0 Wscript.Echo Lpad(FormatNumber((Fix(TargetSize / 1024) / 1024),3)," ", 15) & " M : " & "表示合計" if er = 1 then Wscript.Echo " ( " & target & " のサイズは取得できませんでした )" else Wscript.Echo Lpad(FormatNumber((Fix(AllSize / 1024) / 1024),3)," ", 15) & " M : " & target & " のサイズ" end if Dim fsize : fsize = 0 For Each file in objFolder.files fsize = fsize + file.size Next Wscript.Echo Lpad(FormatNumber((Fix((fsize) / 1024) / 1024),3)," ", 15) & " M : " & target & " 下のファイル" Wscript.Echo ' ************************************************ ' ディレクトリ選択 ' ************************************************ Function SelectDir( strTitle ) Dim obj Set obj = Shell.BrowseForFolder( 0, strTitle, &H4B, 0 ) if obj is nothing then SelectDir = "" Exit Function end if if not obj.Self.IsFileSystem then ErrorMessage = "ファイルシステムではありません" SelectDir = "" Exit Function end if SelectDir = obj.Self.Path End Function ' ************************************************ ' ダブルクォートで囲む ' ************************************************ Function Dd( strValue ) Dd = """" & strValue & """" End function ' ************************************************ ' 指定数、指定文字列左側を埋める ' ************************************************ Function Lpad( strValue, str, nLen ) Lpad = Right( String(nLen,str) & strValue, nLen ) End Function


✅ 結果
✅ データを削除


※ エキスパートモードで表示しています
アーカイブとカテゴリページはこのように簡単に設定できますが、タグページは HTML 設定を直接変更して、以下の『タグページでのみ表示される内容』の記述方法で設定する必要があります


