remove waves by matching string in wave name
tutor
Hi,
I have a bunch of waves each with a specific name. During analysis, my folder is getting too crowded and I would like to delete some of them. Now, the problem is that I would delete only some of it looking at their name, if their name contains a certain string.
Is there a simple way to do that? Is there a function like WaveExists()?
Ex: From waves: pp, pp_norm, pp_interp, pp_interp_ext ===> remove only the waves that contains "_ext"
T
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
I would do it like this:
String strToDelete
String wList = WaveList(strToDelete, ";", "")
Variable nWaves = ItemsInList(wList)
String wName
Variable i
for(i = 0; i < nWaves; i += 1)
wName = StringFromList(i, wList)
KillWaves/Z $wName
endfor
End
Call DeleteWaves("*_ext"). Note that this will only kill waves that are not in use (not displayed in a graph for example).
June 13, 2019 at 03:26 am - Permalink
" During analysis, my folder is getting too crowded..."
Just in case you are not aware of this: I recommend to make use of the /FREE flag for e.g. Make, Duplicate, MatrixOP to avoid clutter.
June 13, 2019 at 07:54 am - Permalink
@sjr51: I think the match string in the WaveList command needs to be something like "*"+strToDelete+"*"
June 13, 2019 at 10:11 am - Permalink
@johnweeks: you're correct since the OP said: remove only the waves that contains "_ext". Given the example, I was thinking the wave must end "_ext".
June 13, 2019 at 12:39 pm - Permalink
@sjr51: Either way there needs to be at least one asterisk. But I guess you're off the hook if any necessary asterisks are included in the input string.
June 13, 2019 at 02:54 pm - Permalink