A bit more straight forward than Endoro's answer. This assumes that the .sql and .tar.gz files always come in pairs.
for /f "skip=6 eol=: delims=" %%F in ('dir /b /a-d /o-d *.tar.gz *.sql') do del "%%F"
Explanation:
The DIR command lists the files sorted by last-modified time stamp in descending order. Type help dir
or dir /?
from the command prompt to get documentation on what all the options mean. The FOR command processes the results. The SKIP option skips the first 6 files, which happens to be the files you want to keep since they sort to the top. The remaining file names are passed to the DEL command. Type help for
or for /?
for documentation on FOR - it is a bit of a beast, with many options.