$ c/ e: A1 c0 t q2 p8 |八 删除当前路径下所有的带后缀.asv的文件1 T" Q/ y" m- a5 @6 Z7 m
说明:该程序具有很好的移植性,用户可以根据自己地2 ?. }* f( x4 [' @& K% D
要求修改程序,删除不同后缀类型的文件! " V) p* b; I; k P5 q: O$ I- Z; T3 L$ T
function delete_asv(bpath) 6 C5 K$ u1 x# c- o3 G3 \" b* S( f
%If bpath is not specified,it lists all the asv files in the current3 \" W5 [, b8 b
%directory and will delete all the file with asv " P# l& [: F- E* H" |% Example:" P: P4 D9 ], W1 U' A" n' v
% delete_asv('*.asv') will delete the file with name *.asv;& L8 A* D2 d' A1 x9 C6 V- S V
% delete_asv will delete all the file with .asv. 0 f& w) C' c- @2 [! c 8 e J% L D* B' X% V# Sif nargin < 1 $ g* ]0 ]# a1 t/ H6 d# s%list all the asv file in the current directory [$ p. b2 A; {+ B: ], Q files=dir('*.asv'); . B9 \' C, H6 }& a) Z% k/ melse1 v+ M9 L9 x6 R4 O- C
% find the exact file in the path of bpath 5 Q5 X, R' A/ u* i4 C, d5 z [pathstr,name] = fileparts(bpath); & y! x" q. ~) y) y8 S& |9 c9 k if exist(bpath,'dir')7 P5 a( p, T$ S4 N; V
name = [name '\*'];! E' U' K: ~9 _# H1 T
end7 g# c0 w* @; X9 l G3 I
ext = '.asv'; : c1 H$ [+ g l+ t8 f# v+ [2 U files=dir(fullfile(pathstr,[name ext])); 0 e+ V' X6 a! v ~end + u! C" x- n! h, l 9 u9 v0 P+ b, }/ b: M V$ Y0 @if ~isempty(files) ) _3 G8 U$ ]4 n5 t' @/ M, Y& A for i=1:size(files,1): ~3 D! X2 B( L7 Q( [8 I2 B
title=files(i).name;; S0 B- k2 m0 @9 F
delete(title); . V+ `! U8 n9 K, [ end( o) U- `9 @( a g
end, b8 f2 ]4 c" X* A7 [2 L
$ u" d/ }' U- m5 p2 U6 p* P K