#!/bin/sh #this is safe for any files that dont have a \n in them, for those all hell breaks loose" find -not -name '.screen' -not -path '* *' -type d -mindepth 1 -printf "%h\n%p\n" > /tmp/$$l while read h ;do read a tmp="$a".optomized$$ for x in touch chmod chown;do $x /tmp/$$h --reference="$h" $x /tmp/$$a --reference="$a" done mkdir "$tmp" find "$a" -mindepth 1 -maxdepth 1 -type d -printf "%p\n%f\n"|while read d;do read n touch /tmp/$$d -r "$d" mv -- "$d" "$tmp"/ touch "$tmp"/"$n" -r /tmp/$$d done find "$a" -mindepth 1 -maxdepth 1 -exec mv -- {} "$tmp"/ \; rmdir "$a" && mv "$tmp" "$a" for x in touch chmod chown;do $x "$a" --reference=/tmp/$$a $x "$h" --reference=/tmp/$$h done done < /tmp/$$l rm /tmp/$$?