% create folder folder_name = datestr(now,'yy_mm_dd_HH:MM'); folder_name = strrep(folder_name,':','_'); mkdir(folder_name) disp(['Creating backup of all modified files to ',folder_name]) % define filename_filelist for the list of modified files filename_filelist = 'file_list.txt'; % define repos base repos_base = '/home/robocup/svn/trunk/src/Turtle2'; % store current path currentpath = pwd; % go to svn folder cd (repos_base) % create a list with all modified files cmd = ['!svn st | grep -E ''^M|^A'' > ',currentpath,'/',folder_name,'/',filename_filelist]; eval(cmd) % go to backup folder cd(currentpath) cd(folder_name) %% open file and read the file list fid = fopen(filename_filelist); C = textscan(fid,'%s %s'); fclose(fid); files = C{2}; % fix for remote tate: 'copied' files in svn for k=1:length(files) if(strcmp(files(k),'+')) files{k}=C{1}{k+1}; end end files = files(~cellfun('isempty',files)); %remove empty strings for k=1:length(files) disp(['Backup : ',files{k}]) % make an hash of the filename including path file_hash = dec2hex(mf_crc32(files{k})); temp = textscan(files{k,:},'%s','delimiter','/'); fname = temp{1}{end}; cmd = ['!cp ',repos_base,'/',files{k},' ./',fname,'_',file_hash]; eval(cmd); end cd(currentpath)