e36freak 1315940141 learn flatten() { find "${1:-.}" -depth \( -type f -exec mv {} "${1:-.}" \; \) -o \( -type d -empty -exec rmdir {} \; \); } ## usage: flatten
e36freak 1315940645 forget
e36freak 1315941268 learn flatten() { find "${1:-.}" -depth \( -type f -exec bash -c 'for f; do fi=${f##*/} t=$fi i=0; while [[ -e $0/$t ]]; do t=$fi.$((++i)); done; mv "$1" "$0/$t"; done' "${1:-.}" {} + \) -o \( -type d -empty -exec rmdir {} \; \); } # usage: flatten
e36freak 1315941499 forget
e36freak 1315941508 learn flatten() { find "${1:-.}" -depth \( -type f -exec bash -c 'for f; do fi=${f##*/} t=$fi i=0; while [[ -e $0/$t ]]; do t=$fi.$((++i)); done; mv "$1" "$0/$t"; done' "${1:-.}" {} + \) -o \( -type d -empty -exec rmdir {} \; \); } # usage: flatten [dir]
e36freak 1315971906 forget
e36freak 1315971911 learn flatten() { find "${1:-.}" -depth \( -type f -exec bash -c 'f=${1##*/} t=$f i=0; while [[ -e $2/$t ]]; do t=$f.$((++i)); done; mv "$1" "$2/$t"' {} "${1:-.}" \; \) -o \( -type d -empty -exec rmdir {} \; \); } # usage: flatten [dir]