File Type Mode Size
Convfile.example file 644 422
README file 644 5259
conv.pl file 755 4744
README
Conv - convert files according to rules

Conv is a utility similar to "make" -- it uses a set of rules (by
default a file called Convfile) to transform files via program
execution.  Conv is considerably simpler than make, though.  Conv
doesn't:

* Recursively resolve inferences - Conv specifies a single command to
  convert from one file format to another.
* Work on arbitrary patterns - Conv's rules only specify how to convert
  from one file extension to another.
* Support a large set of variable manipulation functions - You get
  variable substitution, and that's it.

Which is not to say that conv is useless. Far from it. Conv does:

* Support spaces in filenames - Make doesn't do this (well), and this
  limitation was the primary impetus for creating conv.
* Provide a simple way to batch convert files - A single conv invocation
  can convert all files in a directory to a specified format.
* Support multiprocessing - Conv uses the familiar -j switch to execute
  multiple conversions simultaneously.
* Tell you what it's thinking - The -v switch will shed some light on
  how conv is finding files to convert.
* Do nothing (if you want) - The -n switch will show you what would be
  executed, but stop short of actually executing anything.
* Use alternate rules - The -f <file> switch will use a rule file other
  than Convfile.
* Output to a different directory - The -o <dir> switch will make conv
  put output files in another directory, even if the file you're
  specifying is not in the current directory.

== Invocation ==

conv [-f <file>] [-i <ext>] [-o <dir>|<file>] [-s] [-j <procs>] [-n] [-v]
     <file1> [<file2> ... <filen>]

	-f <file>	Use the specified rule file instead of Convfile.
	-i <ext>	Files specified are input files instead of output
			files, and will be converted to files with the given
			extension.
	-o <dir>|<file>	Place output files in the specified directory or file.
			Note that -o <file> implies -i <ext> using <file>'s
			extension.  Multiple input files can be specified with
			a single output file, but this may not make sense.  On
			the other hand, if your output file is a device or
			fifo, it could make sense.  
	-s		Read filenames from stdin instead of from the
			command-line.
	-j <procs>	Spawn <procs> conversions at once, for
			multiprocessor machines.
	-n		Don't actually do anything. Useful with -v to find out
			what conv is thinking.
	-v		Be more verbose.

It is important to realize that, just like make, the files you are specifying
are the _output_ files, not the input files (unless, of course, you've
specified the -i switch).  The input files are found automatically from the
first matching rule where a file exists.  This means that if you have foo.ogg,
and you want to produce a mp3, you should do this:

$ conv foo.mp3

As a special case, if one of the files specified is exactly '*.<ext>',
conv will try to convert every file in the current directory into a
<ext> file, as though you had typed out "<file>.<ext>" manually for each
file.  Do note that if you actually have any files with extension <ext>
in the current directory, it is likely that your shell will expand the
glob before conv gets the command line.  This might not be what you
expected, so if in doubt, escape the *.

== Examples ==

1. Convert a directory full of flac files to mp3s using lame.

   --Convfile--
   flac => mp3 : lame --quiet -h $< $@
   --cut--

   $ conv *.mp3

2. Convert a movie in AVI format to something an iPod can chew on (but
   you would probably want to use a separate script for the actual
   conversion).

   --Convfile--
   avi => mp4 : ffmpeg -i $< -s 320x240 -vcodec xvid -b 900k -acodec mp3 -ab 96 $@
   --cut--

   $ conv "drift bible.mp4"

== Convfile format ==

A Convfile has a simple format, which some might say looks like a
makefile mated with a perl script.  This was intentional.  :)  Every
line in a Convfile is either blank, or one of two types:

* A rule, which looks like:

  foo => bar : program $< $@

  Which says "Convert files with extension 'foo' to a file with
  extension 'bar' using program 'program'.  $< and $@ mean "input" and
  "output," respectively, and are substituted with the input and output
  filenames, just like make does.  There is also the $* variable for the
  name of the file without the extension.  Note that conv considers an
  extension to be made up of letters and numbers ONLY.  If this isn't
  sufficient, go hack the regex yourself.  :P

* A variable declaration, which looks like:

  foo = bar

  Which says "Set the variable foo to the value 'bar'".  Later, the
  variable can be used by saying $foo.  Unlike make, we don't require
  you to do something silly like put parentheses around the variable
  name.  Variables are case-sensitive, and can be made up of any
  sequence of letters, numbers, and underscores, except that it can't
  start with a number (Why? To be consistent with other things. Again,
  the regex is there).  Variables are not substituted into commands
  until execution, so you could put the variables at the end of the
  file, though I have no idea why you would do that.

You can put comments anywhere in the file as well, they're simply a #
followed by whatever you want up until the end of the line.

Clone: https://git.bytex64.net/conv.git

Recent tags
Tag Date
v0.2 2008-06-03