File: cp.tcl

package info (click to toggle)
sqlcipher 4.11.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 120,460 kB
  • sloc: ansic: 310,189; tcl: 24,097; javascript: 13,561; java: 8,138; sh: 7,586; makefile: 2,448; yacc: 1,727; cpp: 312; cs: 307; sql: 59
file content (28 lines) | stat: -rw-r--r-- 783 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#/usr/bin/tclsh
#
# This is a TCL script that copies multiple files into a common directory.
# The "cp" command will do this on unix, but no such command is available
# by default on Windows, so we have to use this script.
#
#   tclsh cp.tcl FILE1 FILE2 ... FILEN DIR
#

# This should be as simple as
#
#     file copy -force -- {*}$argv
#
# But jimtcl doesn't support that.  So we have to do it the hard way.

if {[llength $argv]<2} {
  error "Usage: $argv0 SRC... DESTDIR"
}
set n [llength $argv]
set destdir [lindex $argv [expr {$n-1}]]
if {![file isdir $destdir]} {
  error "$argv0: not a directory: \"$destdir\""
}
for {set i 0} {$i<$n-1} {incr i} {
  set fn [file normalize [lindex $argv $i]]
  set tail [file tail $fn]
  file copy -force $fn [file normalize $destdir/$tail]
}