BatchFileRename Libraryv1.0

Usage

A simple example wich will rename all txt files within the directory "/path/to/directory/", the renaming rules include:

So if we have a file named eg. "myfile.txt", it will be renamed to eg. "test_myfile.html".

// Include BatchFileRename class file
require ("path/to/BatchFileRename.php");

// Create a new class instance
$obj = new BatchFileRename();

// Define the fileSet filters
$obj->setFileSetOptions(array(
    
"directoryPath" => "/path/to/directory/"
    
"includeExtensions" => array("txt")
    ));

// Define the renaming rules
$obj->setRenameRules(array(
    
"newExtension" => "html"
    
"prefix" => "test_"
    
));

// Rename the files
$obj->rename();

echo 
"Successfully renamed files:";
print_r($obj->getResultArray());

// Check if an error occurs while renaming the files
if($obj->isError()){
    echo 
"Some files were not renamed!";
    
print_r($obj->getErrorsArray());
}