DriveSetLabel

Changes the volume label of the specified drive.

DriveSetLabel Drive , NewLabel

Parameters

Drive

Type: String

The drive letter followed by a colon and an optional backslash (might also work on UNC paths and mapped drives).

On Linux and macOS, specify the volume's mount point instead, such as / or /media/user/BACKUP.

NewLabel

Type: String

If omitted, the drive will have no label. Otherwise, specify the new label to set.

Error Handling

An OSError is thrown on failure, including when the operation is refused for lack of privileges, and on Linux when the volume's filesystem is not one of those listed below.

Remarks

Changing a volume label is a privileged operation on every platform. Expect it to require an elevated process on Windows, and root on Linux and macOS.

Linux

Requires findmnt and the labeling utility for the volume's filesystem: e2label (ext2/ext3/ext4), btrfs filesystem label, xfs_admin, fatlabel (FAT/FAT32/msdos), ntfslabel (NTFS) or exfatlabel.

DriveGetLabel, Drive functions

Examples

Changes the volume label of the C drive.

DriveSetLabel "C:", "Seagate200"