Renaming an external USB hard drive

I have an external external USB drive that I would like to rename from “DATA” to “MORGOTH”.

I’ve tried using this do shell command :

do shell script "diskutil rename /Volumes/DATA /Volumes/MORGOTH" with administrator privileges

I get the following error : error “/Volumes/MORGOTH does not appear to be a valid volume name for its file system” number 1

Why when manually renaming the USB external volume name from “DATA” to “MORGOTH” there are no problem and when using this shell command I get an error.

Thanks!
Daniel

Device is what is returned by diskutil list. It is not a path, and neither is name.

I use Bwana to read manpages in Safari.

Hello.

I like bwana too is good, Here is a collection of all the man pages on OS X sometimes it helps to see what is there.

It is useful to read this page first and remember that a manpage is really for those who knows the command, so a little bit of googling for examples/discussions may prove even more fruitful.

i have done many research on the web and still cannot find what is the right syntax for renaming a volume.

  Rename a volume.  Volume names are subject to file system-specific alphabet and length restrictions.

Is what is written when looking a man pages. The same information is also available when doing Google search.

This is clear in my mind : renaming a volume is not the same as renaming a file. However, I do not see why the do shell script command I wrote do not work. I’ve tried with renameVolume without any success.

in reading “Volumes names are subject to file system-specific alphabet and length restriction” I understand I cannot put anything I want when renaming a volumes and also there is a maximumm number of characters which can depict a name.

This is why, before posting, I had tried to rename the volume with the OSX interface. I also tried it with diskutil in terminal and I was successful.

I do not see anything wrong with the names DATA and MORGOTH for a volume. In my mind this not a privileges question since I was able to do it manually.

However, when applying the whole thing in a do shell command I get an error message.

Is it possible renaming a volume with an applescript via a do shell script command not being possible ?

Daniel

You’re passing a path where a name is required. Try this:

do shell script "diskutil rename /Volumes/DATA MORGOTH" with administrator privileges

Excellent, it does exactly what I wanted to do.

I am trying to understand the man command for Rename. Does it mean device is equal to “/Volumes/Data” and name is equal to “MORGOTH”. I then do not need to pass the path with the name i.e “/Volumes/MORGOTH”

When I read “rename | renameVolume”, I understand either or. I’ve tried and both work.

do shell script "diskutil rename /Volumes/DATA MORGOTH" with administrator privileges
do shell script "diskutil renameVolume /Volumes/DATA MORGOTH" with administrator privileges

Your help has been greatly appreciated.

Daniel

That’s exactly what it is.

The shell interface is completely text based, the input and the output is always text.
For example when you get back an integer 0, it’s actually the string “0”
So there are some rules to distinguish the parameter types.

In terms of diskutil all strings starting with a slash are treated as an absolute path, which is of type device.