Replacing a file with a folder

mconners
Valued Contributor

We discovered a small problem where instead of a ColorSync folder inside of the user template and therefore, inside of student’s home folders, we are seeing a text document called, ColorSync. There MUST be a way to remove this single document and replace with a folder called ColorSync?

If you have any suggestions, we would appreciate your input.

Thanks!

2 REPLIES 2

Look
Valued Contributor III

Something like the following, it will only work for user profiles in /Users but it would check if the file exists and if so replace it with a directory.

Haven't tested it, just reworked something similar I had already.

You would also want to fix the template user (by removing the file there as well) otherwise you will need to keep running the script indefinitely.

Path_To_Check=SomeFolder/SomeFile

for THE_USER in $(ls /Users); do
if [ -f "/Users/$THE_USER/$Path_To_Check" ]; then
echo "Fixing file for $THE_USER"
rm "/Users/$THE_USER/$Path_To_Check"
mkdir "/Users/$THE_USER/$Path_To_Check"
done
else
echo "$THE_USER does not require fixing"
fi
done

Chris_Hafner
Valued Contributor II

Yep, I've come across this too. Actually, in my first test of the year it was REALLY REALLY bad. Killing things like keychains and the like. Just so you know, they will re-create themselves properly if you simply delete them.

FYI, In our original case, ONLY creating users manually via another account on the machine caused this to occur. User accounts created via Casper Imaging or Casper Remote we're A-OK!