Share Pastebin
Guest
Public paste!

Enflat

By: a guest | Mar 19th, 2010 | Syntax: Bash | Size: 0.46 KB | Hits: 80 | Expires: Never
Copy text to clipboard
  1. #!/bin/bash
  2. if test -z $1;then
  3.         echo "Nuffin to enflat?"
  4.         exit
  5. fi
  6.  
  7. function enflat {
  8.         for x in "${@}";do
  9.                 if file "$x"|grep -q directory;then
  10.                         echo "enflattening $x"
  11.                         enflat "$x"
  12.                         rmdir "$x"
  13.                 else
  14.                         echo "enflattening $x"
  15.                         mv "$x" ..
  16.                 fi
  17.         done
  18. }
  19.  
  20. cd $1 && enflat *