Script to mv files and then remove

Hi Guys i'm looking for some help with creating a scripts:

Background - I run alot of testing which creates huge files. This fills up the diskspace over 3 weeks so needs constant deleting. but generally, I keep forgetting!!! so every 3 weeks it fails lol.

Basically i can't format the drive - permissions, key files on share e.t.c. I'm looking for some way to keep the folder structure on the share and remove all the files. The remove takes a long time so i want to somehow background it so i can continue while it removes:

a script to:

  • mount shares (currently 3)
  • create a 'container folder'
  • mv files from the existing folders to the 'container folder' under folder names (leaving existing folders present but empty)
  • remove the newly created container folder with all content as a background tasks
  • the leaves existing empty folders so i can carry on running while this deletes in the background

The first share has 6 folders with files inside it and the second has 5 folders with files. The 3rd folder has only files on the share. I tried just removing "test*" of the share but when the new testing begins some of its files are removed and therefore the tests fail.

The above will mean i can then run the script and when it confirms its started deleting i can begin my new testing on the empty folders

I'v drafted up a script but it looks stupidly long and silly and i know there must be a simpler way to do it!!!

my script below:

#!/bin/sh

share1="/mnt/x"
share2="/mnt/y"
share3="/mnt/z"

printhelp()
{
	echo -e "Syntax: `basename $0` <-f foldername>"
	echo -e "  -f\tName of the folder to copy the files to"
}

mount -o vers=3,proto=tcp,noac,rsize=32768,wsize=32768 192.16.15.172:/za /mnt/x
mount -t nfs4 -o proto=tcp,noac,rsize=32768,wsize=32768 192.16.15.172:/zb /mnt/y
mount -o proto=tcp,vers=3,intr,hard,noac,wsize=16384,rsize=16384 192.16.15.171:/zc /mnt/z

mkdir -p $share1/$1/{big,deep,little,normal,small,wide}
mkdir -p $share2/$1/{big2,deep2,little2,normal2,wide2}
mkdir -p $share3/$1

chmod -R 777 $share1/$1
chmod -R 777 $share2/$1
chmod -R 777 $share3/$1

mv $share1/big/* $share1/$1/big/
mv $share1/deep/* $share1/$1/deep/
mv $share1/little/* $share1/$1/little/
mv $share1/normal/* $share1/$1/normal/
mv $share1/small/* $share1/$1/small/
mv $share1/wide/* $share1/$1/wide/

mv $share2/big2/* $share2/$1/big2/
mv $share2/deep2/* $share2/$1/deep2/
mv $share2/little2/* $share2/$1/little2/
mv $share2/normal2/* $share2/$1/normal2/
mv $share2/wide2/* $share2/$1/wide2/

mv $share3/test* $share3/$1/

rm -rf $share1/$1 &
rm -rf $share2/$1 &
rm -rf $share3/$1 &

echo "Finished!"

Hope you can help and if you need any more info.

Regards

It looks fine, not too many things can be simplified.

------------