Donate for a Beer!

splitbrain.org - electronic brain surgery since 2001

foreach.pl

foreach.pl is a perl script that runs a command on multiple files. It is not as mighty as find's execute function, but much easyier to use and it's syntax should be much better to remember.

The programm accepts various parameters in the given command which are substituted by different parts of the actual filename.

The following parameters can be used:

  • %l full filename (with path)
  • %d directory part of above filename
  • %f filename without directory
  • %b basename of file (no suffix, no directory)
  • %s suffix (without the dot)

The script assumes “<command> %l” as given command when no parameter is used. Special chars in each parameter are quoted by the script.

Download: foreach.tgz

Perl's foreach Syntax

Are you looking for Perl's foreach syntax? Try it at perldoc.com