A script to combine multiple 'section' files (.sec)
to a single output file (.ini for example) follows

Usage:

# paste the text below to a file named combine.tk in a
# directory containing one for more 'section' files named *.sec
# cd to that directory
# (if a output file name is reused, one backup copy is saved (.old))

$ chmod +x combine.tk # make it executable
$ ./combine.tk &


#---------------------------------- begin combine.tk
#!/usr/bin/env wish

set out_suffix .ini
set in_suffix .sec

set ::idx 0
foreach f [lsort [glob *$in_suffix]] {
  set ::files($::idx,name) "$f" 
  pack [checkbutton .f$::idx -text $f -variable ::files($::idx,use)] -anchor w
  incr ::idx
}
pack [label .newname -text NewName:] -anchor w
set ::ename "ini_name$out_suffix"
pack [entry .e -textvariable ::ename]

pack [button .create -text Create -command combine] -expand 1 -fill x
pack [button .dismiss -text Exit -command exit] -expand 1 -fill x

proc popup {msg} {
   tk_messageBox -title "$::argv0" -type ok -message "$msg"
}

proc combine {} {
  set msg ""
  if {"$::ename" == ""} {
    set msg "Cannot use blank file name"
    popup $msg
    return
  }
  if [file exists $::ename] {
    file rename -force $::ename ${::ename}.old
    set msg "$msg\nSaved: ${::ename}.old\n"
  }
  set ct 0
  for {set i 0} {$i < $::idx} {incr i} {
    if $::files($i,use) {
      set msg "$msg\nAdd: $::files($i,name) to $::ename"
      exec cat $::files($i,name) >> $::ename
      incr ct
    }
  }
  if $ct {
    set msg "$msg\n\nCreated $::ename"
  } else {
    set msg "$msg\nNo files selected"
  }
  popup $msg
  return
}
#---------------------------------- end combine.tk
-- 
Dewey Garrett


------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to