Skip to content

Instantly share code, notes, and snippets.

Created October 23, 2018 07:24
What would you like to do?
sample script that loops through all users and sets a different user picture.
# 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
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]}"
if [[ $picindex -eq ${#pictures[@]} ]]; then
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment