how to rename a USB stick using disk number (via terminal and using diskutil)?

Discussion in 'macOS' started by mrjayviper, Apr 14, 2016.

  1. mrjayviper macrumors regular

    Joined:
    Jul 17, 2012
    #1
    Hello. I'm creating a BASH script that will rename the USB stick using diskutil command. From what I've read in the man and various examples, I need to supply the volume name.

    In my situation, the volume name varies so I'm hoping to use disk number (via diskutil list) instead.

    Any ideas on how this can be done? thanks
     
  2. dyt1983 macrumors 65816

    Joined:
    May 6, 2014
    Location:
    USA USA USA
    #2
    How are you getting the disk number from "diskutil list"? The diskutil utility is generally pretty smart, so there are a whole bunch of valid arguments for the rename operation. For instance:

    diskutil rename /Volume/USBSTICK "New Name"
    diskutil rename /dev/disk/2s1 "New Name"

    Will one of those work? It seems like if you're looking in "diskutil list" for something, you probably already know the device name, because the disk number (and the device name) are going to vary depending on the hardware configuration of the machine.
     

Share This Page