import arcpy
import os
try:
for dirpath, dirnames, filenames in os.walk("D:\\researchdata\\MODISdown\\MYD11A1\\LST2003-2017"):
for file in filenames :
if os.path.splitext(file)[1] == '.hdf':
arcpy.ExtractSubDataset_management("D:\\researchdata\\MODISdown\\MYD11A1\\LST2003-2017\\"+file, "D:\\researchdata\\MODISdown\\MYD11A1\\TIFF2003-2009\\"+os.path.splitext(file)[0]+".tif", "0")
break
except:
print "Extract Subdataset example failed."
print arcpy.GetMessages()