sample script that loops through all users and sets a different user picture.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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