dup_filenames=['2010_005937.txt',
'2011_002911.txt',
'2009_004782.txt',
'2009_001057.txt',
'2010_005252.txt',
'2009_005299.txt',
'2010_005532.txt',
'2011_001547.txt',
'2009_002542.txt',
'2010_002817.txt',
'2009_000016.txt',
'2009_003711.txt',
'2009_004394.txt',
'2009_000779.txt',
'2008_006825.txt',
'2009_002784.txt',
'2010_002763.txt',
'2008_008433.txt',
'2008_000270.txt',
'2011_003019.txt',
'2008_005593.txt',
'2009_000449.txt',
'2009_000189.txt',
'2010_002811.txt',
'2011_002594.txt',
'2009_002681.txt',
'2011_003256.txt',
'2011_003166.txt',
'2008_001461.txt',
'2011_000098.txt',
'2009_000416.txt',
'2011_001733.txt',
'2010_003027.txt',
'2009_002346.txt',
'2009_003351.txt',
'2010_001535.txt',
'2011_002983.txt',
'2008_006436.txt',
'2008_000196.txt',
'2008_007169.txt',
'2009_000142.txt',
'2010_000910.txt',
'2008_000082.txt',
'2009_001446.txt',
'2010_003451.txt',
'2009_001774.txt',
'2009_000342.txt',
'2010_003861.txt',
'2008_008590.txt',
'2008_007409.txt',
'2011_001862.txt',
'2010_003976.txt',
'2008_006616.txt',
'2009_002408.txt',
'2009_002370.txt',
'2011_002147.txt',
'2008_008622.txt',
'2009_002192.txt',
'2009_003251.txt',
'2009_004560.txt',
'2010_001939.txt',
'2011_001805.txt',
'2009_001081.txt',
'2008_000036.txt',
'2011_001198.txt',
'2009_004076.txt',
'2010_002531.txt',
'2008_006868.txt',
'2009_001719.txt',
'2009_004099.txt',
'2009_004291.txt',
'2010_005938.txt',
'2010_005193.txt',
'2008_001660.txt',
'2010_003114.txt',
'2009_004593.txt',
'2010_000968.txt',
'2009_003150.txt',
'2009_001470.txt',
'2009_002673.txt',
'2008_000419.txt',
'2009_003129.txt',
'2008_004774.txt',
'2008_002610.txt',
'2009_003522.txt',
'2010_000001.txt',
'2008_006038.txt',
'2010_005049.txt',
'2011_002186.txt',
'2011_001221.txt',
'2008_007021.txt',
'2009_001906.txt',
'2009_000577.txt',
'2009_002522.txt',
'2008_005850.txt',
'2009_003654.txt',
'2011_002414.txt',
'2010_004467.txt',
'2011_001441.txt',
'2009_001605.txt',
'2010_000262.txt',
'2010_002693.txt',
'2009_002972.txt',
'2008_001238.txt',
'2008_004293.txt',
'2010_005658.txt',
'2008_001420.txt',
'2010_004163.txt',
'2009_004193.txt',
'2010_005681.txt',
'2009_003646.txt',
'2009_004264.txt',
'2009_001577.txt',
'2010_005606.txt',
'2008_000227.txt',
'2011_001900.txt',
'2009_001990.txt',
'2010_000694.txt',
'2008_008578.txt',
'2010_001149.txt',
'2009_003605.txt',
'2011_001276.txt',
'2009_001885.txt',
'2010_003331.txt',
'2008_002384.txt',
'2009_000430.txt',
'2011_001662.txt',
'2011_001914.txt',
'2010_005270.txt',
'2008_003272.txt',
'2009_003156.txt',
'2010_003203.txt',
'2010_003971.txt',
'2009_004983.txt',
'2009_002136.txt',
'2008_007344.txt',
'2009_002893.txt',
'2009_004456.txt',
'2010_001514.txt',]

import os	

ori_gaze_root = "/local/wangxin/Data/ferrari_gaze/example_files_with_gaze_annotation/"
new_gaze_root = "/local/wangxin/Data/ferrari_gaze/example_files_with_gaze_annotation_reduced/"
for scale in os.listdir(ori_gaze_root):
	print scale
	folder = ori_gaze_root+scale+'/'
	for fn in os.listdir(folder):
		print fn
		content=[]
		f = open(folder + fn)
		total_num = int(f.readline().strip())
		for line in f:
			flag=True
			for dup_name in dup_filenames:
				if dup_name[:-4] in line:
					total_num-=1
					flag=False
					break
			if flag:
				content.append(line)
		new_f = open(new_gaze_root+scale+'/'+fn,'w')
		new_f.write(str(total_num)+'\n')
		for ele in content:
			new_f.write(ele) 

