BatchFileRename Libraryv1.0

BatchFileRename.php at line 53

Class BatchFileRename

BatchFileRename

public class BatchFileRename

The main BatchFileRename class.

Author:
Mohamed ELkholy
License:
LGPL
Since:
Release: 1.0

Field Summary
BatchFileRenameOptionsFileSet

$fileSetOptions

Contains the configuration options of the files that will be renamed.

BatchFileRenameOptionsBase

$options

Contains the main BatchFileRename configuration options.

BatchFileRenameOptionsRenameRules

$renameRules

Contains the renaming rules which the files will be renamed according to it.

Constructor Summary
void

__construct(array options, array fileSetOptions, array renameRules)

Constructor for initializing the class with default values.

Method Summary
void

setOptions(array options)

Sets the main configuration options.

void

setFileSetOptions(array fileSetOptions)

Sets the FileSet configuration options.

void

setRenameRules(array renameRules)

Sets the RenameRules configuration options.

void

setFileNameVariable(string variableName, callback variableCallback)

Sets a filename Variable.

void

rename()

Used to execute the renaming process.

void

renameFromLogFile(string logfile, bool reverse)

Used to rename files based on a previusly created log file.

void

createLogFile(string logfile)

Creates a log file contains the successfully renamed files and their original names, the log file may be used later to restore the renamed files to their original names by passing the log file back to the renameFromLogFile() method.

array

getResultArray()

Returns an array containing the successfully renamed files.

array

getErrorsArray()

Returns an array containing the files that were not ranamed and the error message.

bool

isError()

Checks if some files were not renamed during the renaming process as a result of such error.

Field Detail

BatchFileRename.php at line 69

fileSetOptions

public BatchFileRenameOptionsFileSet $fileSetOptions

Contains the configuration options of the files that will be renamed.


BatchFileRename.php at line 61

options

public BatchFileRenameOptionsBase $options

Contains the main BatchFileRename configuration options.


BatchFileRename.php at line 77

renameRules

public BatchFileRenameOptionsRenameRules $renameRules

Contains the renaming rules which the files will be renamed according to it.


Constructor Detail

BatchFileRename.php at line 114

__construct

public void __construct(array options, array fileSetOptions, array renameRules)

Constructor for initializing the class with default values.

Parameters:
options - Main configuration options
fileSetOptions - FileSet configuration options
renameRules - RenameRules configuration options

Method Detail

BatchFileRename.php at line 137

setOptions

public void setOptions(array options)

Sets the main configuration options.

Parameters:
options - Main configuration options

BatchFileRename.php at line 149

setFileSetOptions

public void setFileSetOptions(array fileSetOptions)

Sets the FileSet configuration options.

Parameters:
fileSetOptions - FileSet configuration options

BatchFileRename.php at line 161

setRenameRules

public void setRenameRules(array renameRules)

Sets the RenameRules configuration options.

Parameters:
renameRules - RenameRules configuration options

BatchFileRename.php at line 175

setFileNameVariable

public void setFileNameVariable(string variableName, callback variableCallback)

Sets a filename Variable.

Parameters:
variableName - The name of the filename Variable
variableCallback - The callback of the filename Variable
Throws:
InvalidArgumentException

BatchFileRename.php at line 200

rename

public void rename()

Used to execute the renaming process.

Throws:
InvalidArgumentException

BatchFileRename.php at line 235

renameFromLogFile

public void renameFromLogFile(string logfile, bool reverse)

Used to rename files based on a previusly created log file.

Parameters:
logfile - The path of the log file
reverse - If set to TRUE, the method will use the right column as the original file name
Throws:
InvalidArgumentException

BatchFileRename.php at line 322

createLogFile

public void createLogFile(string logfile)

Creates a log file contains the successfully renamed files and their original names, the log file may be used later to restore the renamed files to their original names by passing the log file back to the renameFromLogFile() method.

Parameters:
logfile - The path of the log file to be created
Throws:
RuntimeException - if failed to save the log file

BatchFileRename.php at line 341

getResultArray

public array getResultArray()

Returns an array containing the successfully renamed files.


BatchFileRename.php at line 353

getErrorsArray

public array getErrorsArray()

Returns an array containing the files that were not ranamed and the error message.


BatchFileRename.php at line 365

isError

public bool isError()

Checks if some files were not renamed during the renaming process as a result of such error.