I want to script the Home Folder change within a preference file for NeoOffice so that I can eliminate some work. The test document’s current path on my machine is “MacintoshHD/Users/bstage/Library/Preferences/NeoOffice-1.x/user/basic/script.xlc”. This is the same location for every user with the only change being the name on the Home folder where it resides. I want to changed a path within this XLC doc to reflect the correct Home folder. Without scripting I can open this file in TextEdit and do a Find for the text “change1” and replace it with the account Home name and then save and go along my merry way.
I want to be able to implement this over multiple user accounts so I need to take the users HOME name (shortname works too) and insert it where “change1” is located within this .XLC file. I would prefer to do this behind the GUI and it seems that a shell command would be best for this but I’m yet to find one that will actually go into the file and make the change. So far I have this, but I really don’t know enough about shell commands or AppleScript to see where I’m going wrong.
Here’s what I got. When I wun this script it makes no changes and just creates a backup of the original file which I would prefer it not too.
do shell script "file=\"$HOME/Library/Preferences/NeoOffice-1.x/user/basic/script.xlc\" ; /bin/mv \"$file\" \"$file.backup\" ; /usr/bin/sed -e 's/\"change1\"/\"'`whoami`'\"/g' \"$file.backup\" > \"$file\""
Help my feeble mind!
Browser: Firefox 1.5.0.1
Operating System: Mac OS X (10.4)