|Which files are using most disk space?|
|Find the ten biggest files|
|Find duplicate files bigger than 100MB|
|Find which filetypes are using most space|
|Which directories are using most disk space?|
|Find biggest directories by total file size|
|Find likely-duplicate directories|
|Delete files manually|
|Delete directory trees manually|
|Delete using exec()|
|Delete multiple files using exec()|
|E.g. Recursively delete all files beneath the 'MyProject' directory >100 MB|
|Irreversibly delete multiple directories using exec()|
|E.g. Recursively delete all empty directories beneath the 'MyProject' directory|
First scan your whole drive. This might take up to half an hour, depending on size and type. The following command will do that, saving the scan data to a file called 'wholedisk.crdb'
C:> crab -db wholedisk.crdb C:\
C:> crab -db wholedisk.crdb
SELECT fullpath, bytes/1E9 as GB FROM files
ORDER by bytes DESC LIMIT 10;
SELECT extension, sum(bytes)/1e9 as GB, max(bytes)/1e9, fullpath
GROUP BY extension
ORDER BY GB DESC
This query finds candidate duplicate directories by looking for directories that contain the same total file size, and same number of files.
SELECT p1.pp, p2.pp, p1.size/1e9
(SELECT parentpath as pp, sum(bytes) ||':'|| count(*) as sig, sum(bytes) as size FROM files
GROUP BY parentpath ) AS p1
(SELECT parentpath as pp, sum(bytes) ||':'|| count(*) as sig FROM files
GROUP BY parentpath ) AS p2
ON p1.sig = p2.sig and p1.pp < p2.pp
ORDER BY p1.size DESC
You can run Windows commands to delete or move objects, create directories etc without leaving Crab. Just put an exclamation mark at the start of the line and Crab will send the rest of the line to the shell.
You can use the 'del' command together with the fullpath of a file you want to delete, but the path and filename must be put in quotes. Without the quotes you'll have problems with paths that contain spaces.
Before Windows 10 it was difficult to copy and paste multi-line text, such as long paths, because newline characters were copied for wrapped lines. However, you could get around this by holding down shift when right clicking to copy text - this removes all new lines from the copied text.
Be careful: del will delete files immediately, without putting them in the Trash, there is no Undo
CRAB> !del /f "C:\somepath\File_which_I_am_100_percent_sure_I_dont_need"
You absolutely must put quotes around the fullpath of the directory you want to delete, or a typing mistake could delete everything on your filesystem.
This example deletes the 'MyProject' directory, and every file and directory inside it.
CRAB> !rmdir /s "C:\Users\johnsmith\MyProject\"
CRAB> !rmdir /q /s "C:\Users\johnsmith\MyProject\"
Crab's exec() function runs OS commands on files you specify. If you know what you're doing and don't want to copy files before deleting them, use the 'del' command with its /f option. This causes 'del' to delete files without confirmation, whatever their permissions. Test that the query logic is correct before using it for deletion.
WARNING: If a delete query has no WHERE clause it will delete every file that was scanned.
SELECT exec('del', '/f', fullpath) FROM files
WHERE parentpath like 'C:\Users\johnsmith\MyProject\%' and type = 'f' and bytes>100e6;
Use the 'rmdir' command to delete empty directories.
Tip: Suppress exec() echo to screen
By default exec() outputs every command executed to your screen. If you are running an exec() function hundreds of thousands or millions of times this will be slow, and the screen will be a mess.
To discard the output use the following command before running the query: