Re: Bash Zauberei - Solved
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin Dickopp wrote:
| find ./ -type d | while read i; do
Perfekt!
Unten steht das fertige Skript. (Etwas parameterlos, aber es funktioniert)
Um es zu aktivieren bitte die entsprechenden Zeilen ein/auskommentieren
| Solltest Du allerdings auch Dateinamen haben, die Zeilenumbrüche
| ("Newlines") enthalten, wird es etwas komplizierter:
Ne, Newlines habe ich zum Glück nicht drin :-)
#!/bin/bash
find ./ -type d -depth | while read i; do
~ COUNT=`find "$i" -type f -maxdepth 1| wc -l`
~ if [ $COUNT -gt 0 ]; then
if [ $COUNT -lt 3 ]; then
find "$i" -type f -maxdepth 1 | while read j; do
# mv \"$j\" ..
echo mv \"$j\" ..
done
fi
~ fi
done
#Leere Verzeichnisse loeschen (muss evtl. per Hand nochmal ausgefuehrt
# werden)
find ./ -type d -empty -depth -print0 |xargs -0 rmdir
- --
Bye,
~ Patrick Cornelissen
~ http://www.p-c-software.de
~ ICQ:15885533
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFA7lX24/Hplayn3Y8RAr0bAJ9iiWGvpk61rVWY4bqMKXOgsOgvVgCZAWww
eHKFj3vEGU69wlK1EyNdFqg=
=LGB0
-----END PGP SIGNATURE-----
Reply to: