in reply to rmtree deletes everything inside the folder but doesn't deletes the root folder him self


Just a small remark, but the script is't executed from within the directory you are trying to move, is it?

The permission denied means -most likely- that there is a lock on this directory. So some process is running from within this directory.

Dr. Mark Ceulemans
Senior Consultant
BMC, Belgium