function gen_files(folder)

try
    %folder='18';

    skrypt_start=datestr(now)

    %dzis = datenum(date);
    %dzis = dzis-1;
    %dzis = datevec(dzis);
    dzis=[2010 9 26 0 0 0]; %TU USTAWIAMY DATĘ -1 DLA DNIA KTÓRY CHCEMY PRZETWORZYĆ
    month=num2str(dzis(2));

        if length(month)==1
            month=['0',month];
        else
            month=month;
        end

    destpath = [num2str(dzis(1)),'-',month,'-',num2str(dzis(3))]

    sciezka = ['/repository/camera/processed/temp/',folder]

    cd (sciezka);

    files = dir(fullfile(sciezka,'/*.jpg'));
    [dlx, dly] = size(files(:,:));
    [s1,s2,s3]=size(imread(files(1).name))
    timex=zeros(s1,s2,s3);
    sigma=zeros(s1,s2,1);
    koniec=0;

    for (f=1:1:dlx-1)
            im=imread(files(f).name);
            for j=1:3
                timex(:,:,j)=timex(:,:,j)+double(im(:,:,j));
            end
            %clear im

            if f==1
                %ims1=rgb2gray(imread(files(f).name));
                ims1=rgb2gray(im);
                ims2=rgb2gray(imread(files(f+1).name));
            else
                if mod(f,2)==0
                    ims1=rgb2gray(imread(files(f+1).name));
                elseif mod(f,2)==1
                    ims2=rgb2gray(imread(files(f+1).name));
                end

            end

        f/(koniec-1);
        diff=abs(double(ims2)-double(ims1));
        sigma=sigma+diff;

        koniec=koniec+1
    end

    for j=1:3

        temp1=timex(:,:,j);
        temp2=temp1./koniec;
        timex2(:,:,j)=uint8(temp2);

    end

         %figure(100);
           % imagesc(uint8(timex2));
            %axis off;
            plikti=['/repository/camera/processed/',destpath,'/timex/'];
            mkdir(plikti);
            plikti=['/repository/camera/processed/',destpath,'/timex/',folder,'timex.jpg'];
            imwrite(timex2,plikti);
            %print('-djpeg','-r300',plikti);

        %figure(200);
            %imagesc(sigma);
            %colormap gray;
            %axis off;
            plikva=['/repository/camera/processed/',destpath,'/variance/'];
            mkdir(plikva);
            plikva=['/repository/camera/processed/',destpath,'/variance/',folder,'variance.jpg'];
            y=sigma-min(min(sigma));
            z=y/max(max(y))*255;
            s=uint8(z);
            imwrite(s,plikva);
            %print('-djpeg','-r300',plikva);
end

end