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:\

Next time you start Crab, you can query this same data without scanning again; use the same -db option, and no scan path, e.g.

C:> crab -db wholedisk.crdb

The crab index file, a .crdb file, is typically about 1% of the size of the scanned drive.

N.B Changes you make to the filesystem, such as files or directories you delete, won't be reflected in Crab data until the next scan. If working with old scan data, use the pathexists() function to check whether a file or directory is present at query run time.

Find which filetypes are using most space

We're summing file size by extension, and reporting the biggest file for each.

For each extension we get total file size in GB, maximum file size in GB and the fullpath that gives the max(bytes) function its value.

Which directories are using most disk space?

Find biggest directories by total file size

SELECT parentpath, sum(bytes)/1e9 as GB FROM files GROUP BY parentpath ORDER BY sum(bytes) DESC LIMIT 5;

Find likely-duplicate directories

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 FROM (SELECT parentpath as pp, sum(bytes) ||':'|| count(*) as sig, sum(bytes) as size FROM files GROUP BY parentpath ) AS p1 JOIN (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.ppORDER BY p1.size DESC LIMIT 10;

The sig field is the 'signature' for each directory, calculated from its total file size and number of files.

By restricting the query results to the 10 largest directories we reduce the chance of an accidental match, but you should still compare the candidates file-by-file before deletion.

Delete manually

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.

Delete files manually

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

The /f option forces deletion of files with read-only permissions without further confirmation. Crab doesn't display these confirmation prompts.

Remember that files you delete won't be removed from query results until you scan again.

Delete directory trees manually

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\"

The exclamation mark tells Crab to send the whole line to the shell, and the /s option tells the 'rmdir' command to delete folders and files recursively.

You will be prompted Y/N for each folder that isn't empty. This can be tedious if deleting a lot of folders where each one needs your approval.

There is a still more dangerous form of the command that deletes contents irrespective of their permissions, without asking you for confirmation. This uses the /q option (for "quiet") in addition to the /s option

CRAB> !rmdir /q /s "C:\Users\johnsmith\MyProject\"

Delete using exec()

Delete multiple files using exec()

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.