Home > p2plib > rmdatadirs.m

rmdatadirs

PURPOSE ^

remove data directories from subdirs of appdir (a cleanup tool)

SYNOPSIS ^

function rmdatadirs(varargin)

DESCRIPTION ^

 remove data directories from subdirs of appdir (a cleanup tool)
 typical call (e.g.): rmdatadirs('/home/hu/path/pde2path/demos'); 
 which is also the default if no argument given.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function rmdatadirs(varargin) 
0002 % remove data directories from subdirs of appdir (a cleanup tool)
0003 % typical call (e.g.): rmdatadirs('/home/hu/path/pde2path/demos');
0004 % which is also the default if no argument given.
0005 if(nargin==0); appdir='/home/hu/path/pde2path/demos'; 
0006 else appdir=varargin{1};
0007 end
0008 startdir=pwd; 
0009 cd(appdir); ok=0; allok=0; md=dir; mdl=length(md); 
0010 for i=1:mdl
0011    cf=md(i); 
0012    if (cf.isdir==1 && ~strcmp(cf.name,'.') && ~strcmp(cf.name,'..'))
0013       cd([appdir,'/',cf.name]); 
0014       subdirs=dir; sdl=length(subdirs); 
0015       for j=1:sdl
0016         csubdir=subdirs(j);
0017         if (csubdir.isdir==1 && ...
0018                ~strcmp(csubdir.name,'.') && ~strcmp(csubdir.name,'..'))
0019            fprintf('%s: intending to remove %s \n', cf.name, csubdir.name); 
0020         end
0021       end
0022    end
0023 end
0024 allok=asknu('OK to all?', allok); 
0025 cd(appdir)
0026 for i=1:mdl
0027    cf=md(i); 
0028    if (cf.isdir==1 && ~strcmp(cf.name,'.') && ~strcmp(cf.name,'..'))
0029       cd([appdir,'/',cf.name]); 
0030       subdirs=dir; sdl=length(subdirs); 
0031       for j=1:sdl
0032         csubdir=subdirs(j);
0033         if (csubdir.isdir==1 && ...
0034                ~strcmp(csubdir.name,'.') && ~strcmp(csubdir.name,'..'))
0035            if ~allok
0036              fprintf('%s: intending to remove %s, ', cf.name, csubdir.name); 
0037              ok=asknu('OK?',ok); if ok; rmdir(csubdir.name,'s'); end
0038            end
0039            if allok; rmdir(csubdir.name,'s'); end
0040         end
0041       end
0042    end
0043 end
0044 cd(startdir); % return to calling directory

Generated on Wed 15-Aug-2012 10:09:15 by m2html © 2005