how to delete plist file from ever users library/preference folder with policy

mmichalek
New Contributor

Hello,

I installed GarageBand Loops and they won't show up until the the plist file rebuilds itself. Is there a fast way to delete plist file from every users home folder?

The file name is com.apple.garageband.plist. It works ok for new users, but users with existing accounts do not see the loops.

8 REPLIES 8

Matt
Valued Contributor

Login, Once Per Computer

#!/bin/sh
rm -R "~/Library/Preferences/com.apple.garageband.plist"

rmanly
Contributor III
#!/bin/bash

for dir in /Users/*; do
    if [[ -e "${dir}/Library/Preferences/com.apple.garageband.plist" ]]; then
        rm "${dir}/Library/Preferences/com.apple.garageband.plist"
    fi
done

chris_kemp
Contributor III

Alternatively, you could just pull a working plist from a new user and push it out with FEU checked.

mgrev
New Contributor

Hello all, having a similar issue. I am trying to remove the below file from the library for all users on the computer through a bash script but the wildcard does not seem to do anything. Testing the script locally by running it on mac os x terminal.

File to be deleted: com.apple.eap.bindings.XXXXXXX.plist

#!/bin/bash

for dir in /Users/*;
do
    if [[ -e "${dir}/Library/Preferences/com.apple.eap.bindings.*" ]]; then
        rm "${dir}/Library/Preferences/com.apple.eap.bindings.*"
    fi
done

The script just doesn't delete the required file. I tried removing the quotes as well and still won't delete. What am I doing wrong here please?
Thanks.

jacob_salmela
Contributor II

Test before implementing, but this worked for me--running as root:

#!/bin/bash
for user in /Users/*
do
    for f in "$user"/Library/Preferences/com.apple.eap.bindings.*
    do
    if [ -e "$f" ];then
        echo "Removing $f"
        rm $f
    else
        echo "Files not found in $user"
    fi
    sleep 1
    done
done

Aaron
Contributor II

Why not just use:

rm -f /Users/*/Library/Preferences/com.apple.eap.bindings*

Bash will expand it as necessary.

rmanly
Contributor III

@mgrev

Just for future searchers as I am looking for something from an old thread I participated in and came across this.

The * needs to be outside the quotes.

And @Aaron has the better method for this use case.

antmonge
New Contributor

@mgrev @jacob_salmela I attempted running both of your bash scripts to no avail. The files I am targeting are Microsoft plist files within the CrashReporter folder of each user's home directory.

The issue is: I am not getting any error/syntax messages, yet the plist files remain.

@jacob_salmela's script returns that the "files not found", as the script dictates. @mgrev's script returns nothing, but removes nothing. The separate scripts are below.

#!/bin/sh
for dir in /Users/*
do
    for f in "$dir"/Library/Application Support/CrashReporter/Microsoft*
    do
    if [ -e "$f" ];then
        echo "Removing $f"
        rm -f $file
    else
        echo "Files not found in $dir"
    fi
    sleep 1
    done
done
#!/bin/sh
for dir in /Users/*
 do
if [[ -e "${dir}/Library/Application Support/CrashReporter/Microsoft Word_"*  ]]; then
        rm  "${dir}/Library/Application Support/CrashReporter/Microsoft Word_"*;
    fi
done

I have tried multiple variations of both; moving wildcards and trying different flags. Any help would be appreciated.