begT=datetime(2020,09,01);
endT=datetime(2020,12,31);

begMJD=juliandate(begT)-2400000.5;
endMJD=juliandate(endT)-2400000.5;
batStr= 'T: \n cd apps \n ';

%1.cyklus for pro mjd v rozsahu beg MJD›endMJD
%1.1převést aktuální mjd na datetime

for mjd=begMJD:endMJD
    thisDate=datetime(mjd+2400000.5,'convertfrom','juliandate');
    thisYear=datestr(thisDate,'yyyy');
    thisMonth=datestr(thisDate,'mm');
    thisDay=datestr(thisDate, 'dd');
    dayofYear=day(thisDate,'dayofyear');
   %pridavani nul
    if (dayofYear<100 && dayofYear>=10)          
            dayofYearwithzeros=sprintf('0%d',dayofYear);
    elseif dayofYear<10
            dayofYearwithzeros=sprintf('00%d',dayofYear);
    elseif dayofYear>=100  
        dayofYearwithzeros=sprintf('%d',dayofYear);
            
    end
    %vytvoření jednoho řádku do souboru*.bat
    thisStr=sprintf( 'gfzrnx.exe  -finp T:/Studenti/Geodeti/Nosalkova/novy/%s/%s/%s/5423R48793%s%s%s0000D.20o  -vo 3.4  -smp 30 - | rnx2crx - |gzip> T:/Studenti/Geodeti/Nosalkova/novy/%s/%s/%s/CADM00CZE_R_%s%s0000_01D_30S_MO.crx.gz \r\n',thisYear, thisMonth,thisDay, thisYear, thisMonth,thisDay,thisYear,thisMonth,thisDay,thisYear,dayofYearwithzeros);
    batStr=[batStr thisStr];
    
end
    %zápis do souboru bat
    out=fopen('rungfzrnx.bat','w');
    fprintf(out, batStr);
    fclose(out);
    
