OVERVIEW
cpre is a supplement to the normal cp. The program takes a list of file names and a regular expression substitution pattern, performs the substitution on the file names and then copies each file to the new name that resulted from the substitution.
For instances, if you wanted to swap the band and song names of all of the oggs in a directory, you might do something like this:
$ cpre *.ogg '/(.*) - (.*)/\2 - \1/'
The above would change a file named something like "Iron Maiden - Powerslave.ogg" to "Powerslave - Iron Maiden.ogg".
cpre accepts two flags, '-i' and '-f'. Specifying '-i' will make cpre ask before overwriting the destination file if it exists. Specifying '-f' will cause cpre to overwrite the destination file without asking. If both flags are specified, the last one specified is obeyed. Flags must come before any other arguments.
REQUIREMENTS
ghc (developed with 6.0.1) Text.Regex.Posix (included with GHC, so this shouldn't be an issue) a regex library that ghc supports (like the POSIX C library)
cp (only when building with use-cp)
mv (only when building with use-cp)
INSTALLING
First, edit header.mak to your liking, particularly "installDir", then run
$ ./makemake.pl > Makefile && make && make install
If you don't have perl, edit Makefile instead and try just
$ make && make install
If you are installing to a system wide location (/usr/local/ is the default), then you may need to be root privileges.
USING cp AND mv TO COPY FILES
As of 1.3.0 it is now possible to use an external program (like cp) to do the actual grunt work of copying files. If you make the target use-cp, cpre will use the system's cp command to copy the files. When using the use-cp target, another program, mvre, is also made, which uses mv rather than cp to move files. All command-line options (other than the substitution) will be passed to cp (or mv). You can change what programs cpre uses by editing COPY and MOVE in either header.mak or Makefile.
After editing COPY and MOVE to your liking, build cpre with the command
$ make use-cp
Please note that only the program "cpre" installed with the "make install" command. You'll need to install mvre manually.
INSTALLING WITHOUT GHC
If you do not have GHC, a binary is included that should work with glibc-2.2 (on
x86 Linux).
Edit header.mak or Makefile as above and run
$ make install
LICENSE
You may use cpre and any accompanying files under the terms of the GNU GPL Version 2. See COPYING for details.
cpre is copyright 2004, 2005 Ray Wallace III faboo@ellF.net
