Do shell script: with multiple variables

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!

It’s no problem to use more than one variable. I think you’re missing a space between the 2 variables, thus your command thus is incorrect. I haven’t tried this but try…

do shell script "diskutil rename " & bootpath & space & computername

duh thank you.

I feel dumb now.

you can do:

do shell script "diskutil rename " & bootpath & " " & computername

and that adds the space

thanks

Simple mistakes kill us all, so don’t worry about it.

FYI: you can use " " to put a space in your command, but applescript has keywords that it understands too so you can use words like space, return, or tab (and others) and applescript handles them properly. I find that using the word space is easy because I can quickly see what it is but use whatever you want.

Good luck.