Skip to content

Instantly share code, notes, and snippets.

@atomotic
Created February 15, 2026 12:49
Show Gist options
  • Select an option

  • Save atomotic/3045c26aef0ab1e63dbaeffa003aee95 to your computer and use it in GitHub Desktop.

Select an option

Save atomotic/3045c26aef0ab1e63dbaeffa003aee95 to your computer and use it in GitHub Desktop.
external disk inventory to SQLite with nushell

Usage: catalog-disk <disk_name> <mount_path>

$ nu

> use lib.nu catalog-disk
> catalog-disk photo1 /Volumes/samsung-photo1
> sqlite3 catalog.db .schema
CREATE TABLE IF NOT EXISTS "files"(
"name" TEXT, "type" TEXT, "size" TEXT, "modified" TEXT,
 "disk" TEXT);
export def catalog-disk [disk_name: string, mount_path: string] {
ls (($mount_path | path join "**/*") | into glob)
| select name type size modified
| insert disk $disk_name
| to csv
| save --force $"/tmp/($disk_name).csv"
sqlite3 catalog.db ".mode csv" $".import /tmp/($disk_name).csv files"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment