Tcl Library Source Code

Documentation
Login


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

fileutil::multi::op - Multi-file operation, scatter/gather

Table Of Contents

SYNOPSIS

package require Tcl 8.5 9
package require fileutil::multi::op ?0.5.4?
package require wip ?1.0?

::fileutil::multi::op ?opName? ?word...?
opName option ?arg arg ...?
$opName do ?word...?
into directory
in directory
to directory
from directory
not pattern
for pattern
exclude pattern
but
except
as name
recursive
recursively
copy
move
remove
expand
invoke cmdprefix
reset
(
)
cd directory
up
for-windows
for-win
for-unix
the pattern
the-set varname
-> varname
strict
!strict
files
links
directories
dirs
all
state?
as?
excluded?
from?
into?
operation?
recursive?
strict?
type?

DESCRIPTION

This package provides objects which are able to perform actions on multiple files selected by glob patterns.

At the core is a domain specific language allowing the easy specification of multi-file copy and/or move and/or deletion operations. Alternate names would be scatter/gather processor, or maybe even assembler.

CLASS API

The main command of the package is:

OBJECT API

The following methods are possible for multi-file operation objects:

FILE API

Both object constructor and method do take a list of words and interpret them as file commands to execute. The names were chosen to allow the construction of operations as sentences in near-natural language. Most of the commands influence just the state of the object, i.e. are simply providing the configuration used by the command triggering the actual action.

EXAMPLES

The following examples assume that the variable F contains a reference to a multi-file operation object.

    $F do copy                       \
	the  *.dll                    \
	from c:/TDK/PrivateOpenSSL/bin \
	to   [installdir_of tls]

    $F do move      \
	the  *       \
	from /sources \
	into /scratch  \
	but not *.html

    # Alternatively use 'except for *.html'.

    $F do           \
	move         \
	the  index    \
	from /sources  \
	into /scratch   \
	as   pkgIndex.tcl

    $F do         \
	remove     \
	the *.txt  \
	in /scratch

Note that the fact that most commands just modify the object state allows us to use more off forms as specifications instead of just nearly-natural language sentences. For example the second example in this section can re-arranged into:

    $F do            \
	from /sources \
	into /scratch  \
	but not *.html \
	move           \
	the  *

and the result is not only still a valid specification, but even stays relatively readable.

Further note that the information collected by the commands but, except, and as is automatically reset after the associated the was executed. However no other state is reset in that manner, allowing the user to avoid repetitions of unchanging information. For example the second and third examples of this section can be merged and rewritten into the equivalent:

$F do                   \
    move                 \
    the  *                \
    from /sources          \
    into /scratch           \
    but not *.html not index \
    the  index               \
    as   pkgIndex.tcl

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category fileutil of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.

KEYWORDS

copy, file utilities, move, multi-file, remove

CATEGORY

Programming tools