Skip to content

Instantly share code, notes, and snippets.

@gwparikh
Created March 26, 2016 06:46
Show Gist options
  • Save gwparikh/7762fa9cf1f7860c6d28 to your computer and use it in GitHub Desktop.
Save gwparikh/7762fa9cf1f7860c6d28 to your computer and use it in GitHub Desktop.
Bash alias to flatten a directory (one level at a time, won't clobber files, gives a bit of help)
alias flatten='if dlist=`ls -d */`; then for d in $dlist; do mv -n $d/* ./; done && rmdir $dlist || echo "Error removing directories. There are probably conflicting files." ; else echo "No directories to flatten"; fi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment