Erase flash memory with a start command

I am making a programmer using an Arduino using SPI and SD libraries . I need a command to delete the previous sketch from the target microcontroller but I cant find something on the arduino IDE . Do you know any such command ?

I need a command to delete the previous sketch from the target microcontroller

Why? The new program overwrites the old one when uploaded.

Indeed why ?

And if you erase the Flash before uploading a sketch, the bootloader will be erased.

Avrdude has options for this sort of thing (check the reference) but those are used by the PC when connected to a ISP programmer.

And when all else fails, READ THE DATASHEET. Special attention to chapters 30 and 31.