Hi everyone,
I'm looking for a reliable best practice for a common administrative task: automatically clearing the contents of the Desktop and Downloads folders for our standard (non-admin) student users every time they log in or log out of a MacBook.
I attempted to resolve this by deploying a shell script directly through the Jamf School "Scripts" module. However, after pushing the script to the MacBooks, it did not successfully clean the files from the target folders upon user login or logout.
Environment:
- MDM: Jamf School
- Device Platform: macOS (currently on macOS Sequoia 15.5)
- Target User Accounts: Standard, non-admin users
Here is the script I used:
#!/bin/bash
target_users=("student_ac" "public_user")
current_user=$(/usr/bin/stat -f%Su /dev/console)
if [[ " ${target_users[@]} " =~ " ${current_user} " ]]; then
find "/Users/${current_user}/Desktop" -mindepth 1 -exec mv {} "/Users/${current_user}/.Trash/" \\;
find "/Users/${current_user}/Downloads" -mindepth 1 -exec mv {} "/Users/${current_user}/.Trash/" \\;
fi
exit 0
Has anyone successfully implemented a similar workflow?
Is there a fundamental flaw in my script's logic or syntax that would prevent it from executing correctly?
Using Jamf School's script module is the right approach for this task?
The Jamf School support team suggested I turn to the community for broader expertise, as this question might fall outside the scope of standard support.
Any advice or guidance you could offer would be greatly appreciated.