I’d been asked to find out how we could automate deleting user folders from classroom macs.
Students save their work to the local disks and each academic year the home directories are deleted. Some home directory have to be preserved.
I posted to the Kent Linux user group mailing list and soon had a solution.
Students save their work to the local disks and each academic year the home directories are deleted. Some home directory have to be preserved.
I posted to the Kent Linux user group mailing list and soon had a solution.
Create a file call dir_list containing all the home directorys we want to delete, one per-line :
/Users/user1
/Users/user6
/Users/user33
Then create a file called remove.sh containing:
do
if [ -d $dir ]
then
rm -R $dir
echo “Directory $dir found and deleted.”
else
echo “Directory $dir not found.”
fi
done < dir_list
Run the script with ./remove.sh