image thumbnail

Sending reports and timestamped file by emailing

by

 

29 Oct 2010 (Updated )

Illustrates result updates, activity tracking, timestamping and file zipping, tarr'ing via email.

usageTar_unTarFiles.m
clear all;
% tarFileType = '.zip'; % 1 file extension
tarFileType = '.tar.gz'; % 2 file extensions
tarFileName = 'resultsPackaged';
tarFile = strcat(tarFileName, tarFileType);
secondsMode = {'sec_ON', 'msec_ON', 'sec_OFF'};
secondsMode = char(secondsMode(2));

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% timestamp the file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% fileTimeStamped = timeStampedFile( file );
numberOfFileExtensions = length(strfind(tarFileType, '.'));
tarFile = timeStampedFile( tarFile, numberOfFileExtensions, secondsMode ); % timestamp the file
tarFile = char(tarFile);

% images in this instance
% point to folder 1
imageFolder = 'images';
imageFileTypes = {'*.bmp', '*.jpg'};
contentsInImageFolder = strcat(imageFolder, '\', imageFileTypes);
% point to folder 2
resultFolder = 'resultOutputs';
documentReportFileTypes = {'*.doc', '*.txt'};
contentsInResultOutputs = strcat(resultFolder, '\', documentReportFileTypes);

contentsToBeTarZipped = vertcat(contentsInResultOutputs, contentsInImageFolder);
contentsToBeTarZipped = contentsToBeTarZipped(:)';
% contentsToBeTarZipped = sort(contentsToBeTarZipped);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tar pack the files
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tar(tarFile, contentsToBeTarZipped); % max = 2 GB

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% extract the zipped contents
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
folderToBeExtractedTo = 'viewTarContents';
untar(tarFile, folderToBeExtractedTo);

Contact us