#!/bin/zsh setopt extendedglob no_unset cd $0:h/done || exit $? current=( *(@) ) keep=( $current:A:t ) for d in *(/); do if (($+keep[(r)${d:t}])); then print -r keep: $d else btrfs sub del $d fi done