JM Jan-31-2017 Combining code from
base conversion and
color values available for syntactic use in Tcl scripts, one could add some visual indication of files with likely same content.
console show
package require cksum
pack [frame .c -relief ridge -bd 2] -fill both -expand 1
set canvas [canvas .c.canvas -yscrollcommand ".c.sy set" \
-width 300 -height 400 -relief raised -bd 2]
scrollbar .c.sy -orient vert -command "$canvas yview" -bd 1
pack .c.sy -side right -fill y
pack $canvas -fill both -expand 1
proc hex {num} {
set res {}
set hex_list {0 1 2 3 4 5 6 7 8 9 A B C D E F}
while {$num / 16 != 0} {
set rest [expr {$num%16}]
set res [lindex $hex_list $rest]$res
set num [expr {$num/16}]
}
set res [lindex $hex_list $num]$res
}
set mark 0
foreach file [glob *] {
if {[file type $file] == "file"} {
set checksum [hex [crc::cksum -file $file]]
puts "$file [file type $file] $checksum"
set i [string range $checksum 0 5]
scan $i "%2x%2x%2x" r g b
if {($r+$g+$b)<350} { set col white } else { set col black }
set i \#$i
$canvas create rect 0 $mark 400 [incr mark 30] \
-fill $i -outline {} -tags $i
$canvas create text 220 [expr $mark-15] -text "$file ($checksum)" -fill $col -tags $i -anchor ne
}
}