I have a pretty simple script that makes some system setting changes with a little user interface.
It works in its current configuration however it could be better. The very last shell script renames the volume to whatever variable you give it, however it doesnt know which Volume your actually booted from. Right now it just assumes that its the default boot volume, using the disk ID “disk0s2”
set userCanceled to false
set bootvolume to (boot volume of (system info))
set bootpath to "/Volumes/" & bootvolume
try
display alert ¬
"Is this the correct Volume name?
" & bootvolume buttons {"No", "Yes"} ¬
default button "Yes" cancel button ¬
"No" giving up after 30 ¬
as warning
on error number -128
set userCanceled to true
end try
if userCanceled then
-- statements to execute when user cancels
display dialog "Insert Computer Name" default answer "" buttons {"OK"} default button 1
set computername to text returned of result
do shell script "scutil --set ComputerName " & computername with administrator privileges
do shell script "scutil --set LocalHostName " & computername with administrator privileges
do shell script "diskutil rename disk0s2 " & computername
display dialog "Computer Name has been changed to: " & computername
end if
The syntax for renaming the volume requires you to specify the volume, then specify the new name
“diskutil rename MountPoint|DiskIdentifier|DeviceNode newName”
I would like to replace that disk Identifier with a Applescript variable.
So something like:
do shell script "diskutil rename " & bootpath & computername
But I cant seem to pass more than one variable on to the shell script
Any help would be great, thanks!