#!/bin/bash -e if [[ "$1" = "" ]] then echo "Usage: $0 directory" echo "Adds a .preserve-dir file to all empty directories" exit 1 fi find "$1" -type d -empty -not -path "*/.git/*" -printf "%p/.preserve-dir\0" \ | xargs -0 -r touch