Created
October 23, 2018 07:24
-
-
Save scriptingosx/2bc337d3a7f6c81fcb869d71ce3619ca to your computer and use it in GitHub Desktop.
sample script that loops through all users and sets a different user picture.
This file contains hidden or 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