Version 2 of Hard Archiving Strategy using Tcl as master control

Updated 2011-07-27 10:57:42 by RLE

[An introductory, narrative, explanation of what your code is intended to perform here would be most helpful. Not everyone here will be familiar with the term "Hard Archiving".]


(in progress)

Step 1. Scan local path and select files for archival. Create cover sheet.

hard_archive.tcl

set master "\n
Hard Archive \"pwd\"
Path Time: [file mtime [pwd]
Time this script was executed: clock seconds
[clock format [clock seconds]
Epoch time (clock format 0)

Legend: 
\"Filename\" [ModifyTime\] [FileSize\] \"File Type\"
Please refer to documentation for information regarding
file types, times and sizes

"

set files glob *

foreach x $files {
        if { file type $x == "file" } {
                append master "\"$x\" [file mtime $x\] [file size $x\] \"exec file -b $x\"\n"

                exec ./a.exe -e $x out.txt

        }
}

puts $master

[Unless I am missing something, your foreach x $files loop appears to overwrite out.txt with each new file, such that at the end of the loop, the only data in out.txt is the data from the final filename in $files.]


Note: a.exe is my hacked version of b64 (C) Copr Bob Trower 1986-01. (I added line numbering and CRC24 checksum to each line) source code here: http://www.nefyou.com/b64-modified.c.txt

Step 2. Generate Quick Response Code images for out.txt

testout.tcl

exec rm -Rf work
exec mkdir work     
set fp open "out.txt" r
fconfigure $fp -buffering line
set mc 10
set lc 1
set process ""

gets $fp data
while {$data != ""} {
        append process "$data\\n"
        set lc incr lc
        if { $lc>5 } {

                exec ./qrencode-3.1.1/qrencode.exe -o work/$mc.png -s 3 -8 "$process"
                
                set mc incr mc 10

                 set process ""
                set lc 1
        }
          gets $fp data
     }
     close $fp
exec ./qrencode-3.1.1/qrencode.exe -o work/$mc.png -s 3 -8 "$process"

[I am curious as to why you did not use file delete for "exec rm -Rf work" (file delete -force work), and why you did not use file mkdir for "exec mkdir work", thereby avoiding two exec calls. Also, if you want your "$md.png" files to be processed in order, you might consider [format "work/$08d.png" $mc] within your exec call to produce zero filled names, which will sort in numeric order. At the moment, as soon as you hit 100.png your sort order of files will be wrong.]


Note: qrencode is http://fukuchi.org/works/qrencode/index.en.html

Step 3: put png together in pdf

working... need to merge step 1&2 7z data is possible, it is well documented compression but adds another level of complexity.

RLE (2011-07-29) Tcl 8.6 includes built in zlib functionality, so you could "gzip" the data completely from within Tcl, reducing the complexity when compressing the data.