SourceForge.net Logo

wc2fn -- wildcards in target filenames
Download

Introduction

The tool wc2fn (wildcards2filenames) is a wrapper for programs and shell commands that expect pairs of filenames. For historic reason --the wrapper was first written for copy and move commands-- the first filename of the pair is referred to as 'source', the second as 'target'. The set of source files is selected by matching a wildcard pattern (Unix glob); a corresponding set of target filenames is generated by wc2fn by expanding the target pattern. The target pattern is also provided in wildcard format.
Since the target filenames are only generated, files with those names can either exist, or can be created during the process, or may be just listed.
After the set of source:target filenames is created the specified program or shell command is executed for each source:target pair.
If this sounds rather abstract have a look at the Examples.

Notation used in documentation and Usage message

Details and assorted notes (needs more work)

Source file match and target name generation are performed by using the python modules glob, fnmatch and os.path -- the shell has to be prevented from wildcard expansion by quoting source and target patterns.
The actual work horse that does the match/replace is the included python class Wildcards2Filenames; python programmers can import the module and use this class to write their own front-end.
Currently only regular files are processed, directories, symlinks, etc. are ignored.

wc2fn can be used in several ways:
- General form in which a shell command [with options], and source and target pattern are provided.
- Frequently used shell commands can be wrapped for ease of use; the syntax of the wrapper resembles that of the original command, e.g.
"cp source-file target-file" becomes "wccp 'source-pattern' 'target-pattern'
- python programmers import the module and write their own command line front-end.

How target filename generation works

Installation