I have a piece of code which runs four other pieces of code. However when those codes run they write their out put writes to the directory I run this code in. I was wondering if there is a way to run the code so it changes directory after every time, here is my code:
loop=np.arange(187761,187854)
for ext in loop:
ext=str(ext)
s0=''
dcom=["rm *.txt"]
dcom=s0.join(dcom)
nes=os.system(dcom)
a=sys.argv[1]
com=['cd /cygdrive/e/desar2.cosmology.illinois.edu+7443/DESFiles/desardata/OPS/red/', a,'/red/DECam_00',ext, '/']
com=s0.join(com)
print com
sres=os.system(com)
com=['python /home/pythoncodes/other4.py ', '00'+ext]
com=s0.join(com)
print com
sres=os.system(com)
com=['python /home/pythoncodes/correctedmo.py ', '00'+ext]
com=s0.join(com)
print com
sres=os.system(com)
com=['python /home/pythoncodes/graphs.py ', '00'+ext]
com=s0.join(com)
print com
sres=os.system(com)
com=['python /home/pythoncodes/whiskerother4.py ', '00'+ext]
com=s0.join(com)
print com
sres=os.system(com)
I was hoping the top part would change the directory for every ext, but it doesn't. Is there a way to do this or should I just alter the programs to write to different directories?