DirectoryFeeder.java
import java.io.*;
import java.util.*;

/**
 * Simple utility app to drip feed files from a source directory to
 * a target directory in batches of a specified size, at specified
 * intervals. Subdirectories are not moved, only files. This application
 * will run infinitely unless interrupted, even after the source
 * directory is empty.
 * <p>
 * Runtime parameters required:
 * <ul>
 *    <li>Full path to the source directory
 *    <li>Full path to the target directory
 *    <li>Maximum number of files to move per batch
 *    <li>Number of milliseconds to pause between moving batches
 *    <li>Optional list of file extensions for files to be moved, e.g.
 *        .txt .xml .doc. If no such list is supplied, all file types
 *        are moved by default
 * </ul>
 *
 * @author Michael Fitzmaurice, October 2002
 */
public class DirectoryFeeder
{
    public static void main(String[] args)
    {
        File sourceDir            = new File(args[0]);
        File targetDir            = new File(args[1]);
        int batchSize             = Integer.parseInt(args[2]);
        long sleepTime            = Long.parseLong(args[3]);
        FilenameFilter filter     = null;

        if (args.length > 4)
        {
            int numExtensions     = args.length - 4;
            String[] extensions   = new String[numExtensions];
            System.arraycopy(args, 4, extensions, 0, numExtensions);
            filter = getFilenameFilter(extensions);
        }

        while (true)
        {
            System.out.println("Scanning " + sourceDir + " for files to move");

            String[] sourceFiles  = sourceDir.list(filter);
            int filesMoved        = 0;

            for (int i = 0; i < sourceFiles.length; i++)
            {
                if (filesMoved == batchSize)
                    break;

                String nextFile   = sourceFiles[i];
                File sourceFile   = new File(sourceDir, nextFile);
                File targetFile   = new File(targetDir, nextFile);

                // do not move directories
                if ( sourceFile.isDirectory() )
                    continue;

                boolean movedFile = sourceFile.renameTo(targetFile);

                if (movedFile)
                {
                    System.out.println( "Moved " + nextFile + " from "
                                         + sourceDir + " to " + targetDir);
                    filesMoved++;
                }
                else
                {
                    System.out.println( "FAILED TO MOVE " + nextFile + " from "
                                         + sourceDir + " to " + targetDir);
                }
            }

            try
            {
                System.out.println("Sleeping for " + sleepTime + " milliseconds");
                Thread.sleep(sleepTime);
            }
            catch (InterruptedException ie)
            {
                ie.printStackTrace();
            }
        }
    }

    private static FilenameFilter getFilenameFilter(String[] fileExtensions)
    {
        int numberOfFileTypes    = fileExtensions.length;
        final Set fileTypes      = new HashSet(numberOfFileTypes, 1.0f);

        for (int i = 0; i < numberOfFileTypes; i++)
        {
            fileTypes.add( fileExtensions[i].toUpperCase().trim() );
        }

        return new FilenameFilter()
        {
            public boolean accept(File dir, String name)
            {
                String extension  = name.toUpperCase();
                int indexOfDot    = extension.indexOf(".");

                if (indexOfDot != -1)
                    extension = extension.substring(indexOfDot);

                // :NB: purposefully let files of 0 bytes through
                return fileTypes.contains(extension);
            }
        };
    }
}

DirectoryFeeder.java