Bulk kill and duplicate

Function bduplicate(prefix, filter)
//@@@@@@@@@@@@@@@@@@@@@@@@@
//---------------------------------
// filter waves with wildcards to duplicate particular waves
// additonal options for filter:
// set "all" to duplicate every wave in current data folder
// set "onGraph" to duplicate the traces on a graph
// no string set for filter defaults to the "onGraph" setting.
// V2.0
    String prefix, filter       // prefix to append and filter or wildcard string
    String wName, newName
 
    String list
    if(strlen(filter)==0)
        list = TraceNameList("",";",1)
        printf ": duplicating waves from graph\r"
    elseif(cmpstr(filter, "onGraph")==0)
            list = TraceNameList("",";",1)
            printf ": duplicating waves from graph\r"
        elseif(cmpstr(filter, "all")==0)
        list = WaveList("*",";","")
        printf ": duplicating all waves in current folder\r"
    else
        list = WaveList(filter,";","")
        printf ": duplicating waves filtered by the wildcard " + filter + "\r"
    endif
   
    if (strlen(prefix)==0)
            prefix = "corr_"
    endif

    Variable numItems = ItemsInList(list)
    if (numItems == 0)
        return 0
    endif
   
    Variable index 
    for (index=0;index<numItems; index+=1)
        wName = StringFromList(index,list)
        sprintf newName, "%s%s", prefix, wName
        Duplicate/O $wName $newName
    endfor
End

Function bkill(filter)
//@@@@@@@@@@@@@@@@@@@@@@@@@
//---------------------------------
// filter waves with wildcards to kill particular waves
    String filter
    String list = WaveList(filter,";","")
    printf ": killing waves filtered by the wildcard " + filter + "\r"
    Variable numList = ItemsInList(list)
    if (numList == 0)
        return 0
    endif
   
    Variable index 
    for (index=0;index<numList;index+=1)
        KillWaves/Z $(StringFromList(index, list))
    endfor
End

Forum

Support

Gallery

Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More