DiskUtil Applescript Question

Hi Guys,

Im having a issue getting this to work correctly. I am creating a secure erase for USBs via apple script.

So Far i have:


do shell script "diskutil zeroDisk /Volumes/TEST"

This zeros out the data, however, does not name the disk, and i stil have to fo into DiskUtil in Utils and then reformat.

I get the following as a result:

Result:
error “Usage: diskutil zeroDisk MountPoint|DiskIdentifier|DeviceNode
Write zeros across the given whole-disk or partition.
After this operation, a whole-disk will need to be partitioned; a partition
will need to be erased (newfs’d), in order to be used again as a volume.
Ownership of the affected disk is required.” number 1

I am confused on what i need to do. I have done a lot of research but i cant see what i need to do (although it is probably is staring me in the face :frowning: )

 zeroDisk device
            Erase a device, writing zeros to the media.  The device can be a whole-disk or a partition.
            In either case, in order to be useful again, zero'd whole-disks will need to be partitioned,
            or zero'd partitions will need to be erased (newfs'd), e.g. by using the partitionDisk or
            eraseDisk verbs.  If you desire a more sophisticated erase algorithm or if you need to erase
            only free space not in use for files, use the secureErase verb.  Ownership of the affected
            disk is required.

 partitionDisk device [numberOfPartitions] [[APM]Format | [MBR]Format | [GPT]Format] [part1Format
            part1Name part1Size part2Format part2Name part2Size part3Format part3Name part3Size ...]

            (re)Partition a disk, removing all volumes.  All volumes on this disk will be destroyed.
            The device parameter specifies which whole disk is to be partitioned.  The optional
            numberOfPartitions parameter specifies the number of partitions to create; if given then the
            number of parameter triplets (see below) is expected to match; else, the number of triplets
            alone given will determine the number of partitions created.

            The optional partitioning scheme parameter forces a particular partitioning scheme; if not
            specified, a suitable default is chosen.  They are:

                  ¢   [APM]Format specifies that an Apple Partition Map scheme should be used.  This is
                      the traditional Apple partitioning scheme used to start up a PowerPC-based Macin-
                      tosh computer, to use the disk as a non-startup disk with any Mac, or to create a
                      multiplatform compatible startup disk.

                  ¢   [MBR]Format specifies that a Master Boot Record scheme should be used.  This is
                      the DOS/Windows-compatible partitioning scheme.

                  ¢   [GPT]Format specifies that a GUID Partitioning Table scheme should be used.  This
                      is the partitioning scheme used to start up an Intel-based Macintosh computer.

            For each partition, a triplet of the desired filesystem format, volume name, and size must
            be specified.  Several other diskutil verbs allow these triplets as well (and for them, the
            numberOfPartitions parameter is also optional).  The triplets must be as follows:

                  ¢   Format names are of the form HFS+, MS-DOS, etc.; a list of formatable filesystems
                      and common aliases is available from the listFilesystems verb.  You can specify
                      Free Space to skip an area of the disk.  Format guides diskutil both in what par-
                      tition type to set for the partitions (slices) as well as what filesystem struc-
                      tures to lay down therein, e.g. with the appropriate newfs_* (8).

                  ¢   Names are the initial volume names; they must conform to filesystem-specific
                      restrictions.  If a name of %noformat% is specified, then the partition is left
                      blank such that the partition space is carved out, the partition type is set
                      according to the filesystem format name, the partition space is partially erased,
                      but a filesystem structure is not laid down; this is useful in certain cases e.g.
                      when setting up ZFS pools.  For Free Space triplets, names are ignored but dummy
                      names must be present.

                  ¢   Sizes are floating point numbers followed by a letter or percent sign as described
                      in the sizes section at the end of this page (e.g. 165536000B, 55.3T, 678M, 75%,
                      R).

            The last partition may be lengthened to the end of the disk.  You can specify an exact size
            for your last partition by specifying it as the penultimate triplet and specifying an addi-
            tional (last) triplet as Free Space.

            Ownership of the affected disk is required.

http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/diskutil.8.html

Am Running with this so far, but sure its a clunky way:


do shell script "diskutil eraseVolume HFS+ Name /Volumes/TEST"
do shell script "diskutil secureErase freespace 0 /Volumes/Name"