remove waves by matching string in wave name

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

I would do it like this:

Function DeleteWaves(strToDelete)
   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).

" 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.

 

@sjr51: I think the match string in the WaveList command needs to be something like "*"+strToDelete+"*"

@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".

@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.

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More