Slicer3:LUTs and Ontologies:Renumber Script

From Slicer Wiki
Jump to: navigation, search
Home < Slicer3:LUTs and Ontologies:Renumber Script

Edit as needed to renumber wiki tables of slicer colors:

set fpin [open "~/tmp/colors.wiki"]
set fpout [open "~/tmp/colors2.wiki" "w"]

set index 0
while { ![eof $fpin] } {
  set line [gets $fpin]
  if { [scan $line "|%d" oldindex] != 1 } {
    puts $fpout $line
  } else {
    puts $fpout "|$index"
    incr index
  }
}

close $fpin
close $fpout