View Single Post

  #7 (permalink)  
Old 07-21-2006, 03:11 AM
nixcraft's Avatar
nixcraft nixcraft is offline
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,103
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You need to read files on fly and copy them using some tricks:

Code:
#!/bin/sh
SEARCHDIR="$1"
DESTDIR="$2"

find $SEARCHDIR-name "*[HH]*.doc" -exec echo '{}'  \; | while read LINE
do
f="$LINE"
d=$(dirname "$f")
ff=$(echo "$f" | awk -F"$d" '{ print $2}')
mydir=$(echo $ff | cut -b1-5)
mkdir $DESTDIR/$mydir
Coping file: $f => $DESTDIR/${mydir}${ff}
cp "$f" "$DESTDIR/${mydir}${ff}"
done
hope this helps. Read above code carefully till u understand it very well...
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote