import os,sys,os.path
print('your current dir is {}'.format(os.getcwd()))
if len(sys.argv)==1:
while True:
sourceDir=input('input source dir:')
if os.path.exits(sourceDir):
break
else:
print('no such dir,try again:')
targetDir=input('input target dir:')
elif len(sys.argv)==3:
sourceDir=sys.argv[1]
targetDir=sys.argv[2]
if not os.path.exists(sourceDir):
print('Source dir do not exist')
sys.exit()
else:
print('usage:transmitter [sourcedir targetdir]')
sys.exit()
if not os.path.exits(targetDir):
os.mkdir(targetDir)
cFiles = [ f for f in os.listdir(sourceDir) if ('.c' in f or '.h' in f)]
for f in cFiles:
open(os.path.join(targetDir,f),'wb+').write(
open(os.path.join(sourceDir,f),'rb').read())