Batch edit computer names to be FQDN

Batch edit computer names to be FQDN

avatar

I am running the free version of RDM for Mac. I would like to use an AppleScript to rename the machines that don't already have my local domain appended to the computer names. Some of them already have the FQDN, though.

I would like to run an AppleScript similar to this but have it only append the domain name if the domain name is not already present in the computer name:

set _host to get value from _connection of property "Host"
set value of _connection of property "Host" to _host & ".mydomain.com"
save _connection


I imagine it would look something like this (I know this completely wrong syntax):

set _host to get value from _connection of property "Host"
set value of _connection of property "Host" to _host & ".mydomain.com" if "Host" does not equal "_host+.mydomain"
save _connection


Can someone tell me what AppleScript I can use that can accomplish what I'm after?

All Comments (1)

avatar

Hi blakelewis,

The following script should do what you want:

set _host to host of _connection
if _host does not end with ".mydomain.com" then
	set host of _connection to _host & ".mydomain.com"
	save _connection
end if


Best regards,

Xavier Fortin