wm title . "regexp change"
wm resizable . 0 0
frame .labels
frame .entries
label .labels.from -text "From:"
entry .entries.from -width 20 -textvariable from
label .labels.to -text "To:"
entry .entries.to -width 20 -textvariable to
button .labels.show -text "Show" -command show
button .entries.change -text "Change" -command change
pack .labels.from .labels.to .labels.show
pack .entries.from .entries.to .entries.change -fill x
pack .labels .entries -side left
set from ".*"
set to "&"
proc show {} {
global from
global to
set command "for i in *; do echo mv \\\"\$i\\\" \\\"\$(echo \$i | sed 's/$from/$to/')\\\"; done"
puts [exec bash -c "$command"]
puts "------------"
}
proc change {} {
global from
global to
set command "for i in *; do mv \"\$i\" \"\$(echo \$i | sed 's/$from/$to/')\"; done"
catch {exec bash -c "$command"} { }
}