| 
<?php
/*
 * A simple example that renames a set of files by auto-numbering them with a prefix.
 *
 * @package        BatchFileRename
 * @author        Mohamed ELkholy <[email protected]>
 * @copyright    Copyright (c) 2012 Mohamed Elkholy
 * @version        SVN: $Id: simple.autoNumber.php 5 2012-04-17 18:53:36Z admin $
 * @license        LGPL <http://www.gnu.org/licenses/lgpl.txt>
 * @link        http://www.phpclasses.org/package/7472
 */
 
 // Include BatchFileRename class file
 require ("../src/BatchFileRename.php");
 
 // Create a new class instance and enable simulation mode
 $batchFileRename = new BatchFileRename(array(
 "simulationMode" => true,
 ));
 
 // Define the fileSet filters
 $batchFileRename->setFileSetOptions(array(
 "directoryPath" => "/path/to/directory/",
 "includeExtensions" => array("txt"),
 ));
 
 // Define the renaming rules
 $batchFileRename->setRenameRules(array(
 "prefix" => "<##> - ",
 ));
 
 // Rename the files
 $batchFileRename->rename();
 
 echo "<pre>";
 
 echo "Successfully renamed files:";
 print_r($batchFileRename->getResultArray());
 
 // Check if an error occurs while renaming the files
 if($batchFileRename->isError()){
 echo "Some files were not renamed!";
 print_r($batchFileRename->getErrorsArray());
 }
 
 echo "</pre>";
 |