function package_ev()

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EV script 011 - Package EV file and associated data into one volume
% Useful if moving EV files around, or sharing with others.
% Example Echoview COM script originally submitted to the Echoview forum by Tim Ryan (CSIRO Oceans and Atmosphere)
% Downloaded from www.echoview.com
% For assistance, contact Echoview support <support@echoview.com>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


EvApp = actxserver('EchoviewCom.EvApplication');

[evfilename, evfilepath] = uigetfile('*.ev','select ev file','Z:\echoview_worksheet');
ev_file = [evfilepath evfilename];        

output_dir = uigetdir('','Select output directory');

% copy the ev file to the new location
m=max(strfind(ev_file,'\'));
NewEvFile = [output_dir '\' ev_file((m+1):end)]   
copyfile(ev_file,NewEvFile);

% The EvFile object accesses information about and performs actions on an EV file.
ev_file = NewEvFile

try
    EvFile = EvApp.OpenFile([ev_file]); % open the copied ev file in the output directory
catch
    keyboard
end 


% now copy the data files to the output directory and link them into the
% copied ev file.
    for i=1:EvFile.Filesets.Count; % for each fileset
        for j=1:EvFile.Filesets.Item(i-1).DataFiles.Count
            oldfilename = EvFile.Filesets.Item(i-1).DataFiles.Item(j-1).FileName;
            newfilename = [output_dir '\' oldfilename(max(strfind(oldfilename,'\')+1):end)];
            copyfile(oldfilename, output_dir);
            oldf=EvFile.Filesets.Item(i-1).DataFiles.FindByFileName(oldfilename);        
            EvFile.Filesets.Item(i-1).DataFiles.Remove(oldf); 
            try
                EvFile.Filesets.Item(i-1).DataFiles.Add(newfilename);
            catch
                keyboard
            end
        end
    end
% save the ev file and job is done
EvFile.Save();

