Instantly share code, notes, and snippets.

Embed
What would you like to do?
sample script that loops through all users and sets a different user picture.
#!/bin/bash
# create an array from all images in the User Pictures subfolders
IFS=$'\n' read -rd '' -a pictures <<< "$(find '/Library/User Pictures/Fun' -name *.tif -print )"
# loop through all users
picIndex=0
userList=$(dscl . list /Users UniqueID | awk '$2 > 500 {print $1}')
for user in $userList; do
echo "$user"
# delete JPEGPhoto
dscl . delete "/Users/$user" JPEGPhoto
# update path in picture
echo ${pictures[$picindex]}
dscl . create "/Users/$user" Picture "${pictures[$picindex]}"
((picindex++))
if [[ $picindex -eq ${#pictures[@]} ]]; then
picindex=0
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment