Reputation: 719
I want to delete all files that start with letter 'f'
in a folder. This is what I've tried:
delete (fullfile(datapath,folder_name),sprintf('^%s.*\.nii$','f'));
For some reason when I do this, I get the error that \.
isn't a valid control character and also it thinks that I want to delete the entire directory. Could anyone tell me how to fix this issue?
Upvotes: 0
Views: 31
Reputation: 8401
sprintf
is primarily aimed at formatting data into a string format and doesn't work with RegEx expressions. However, delete
's wildcard *
should suffice here according to this example:
delete(fullfile(datapath,folder_name,'f*.nii'));
Upvotes: 3