BatchFileRename is a PHP utility library that provides a fully automated solution
for renaming multiple files at once based upon flexible criteria. It can traverse given directory and
rename files that match given patterns. The files are renamed according to rules. For example, you include
sequence numbers to the new filenames, add a prefix or suffix, change three letters with four other letters
in a filename, change the filename case to upper, lower case or even camelCase.
There are lots of ways to manipulate filenames.
- Files are selected & renamed based on a flexible criteria.
- Include & Exclude a specific file types, extensions from being renamed.
- Use Regular Expressions or user-defined callback to filter specific files from being renamed.
- Full multibyte support for non-english filenames.
- Full support for Regular Expressions.
- Change the file name, or use a fixed filename.
- Convert the extension to lower case, upper case - or replace it - or add a secondary extension - or remove it - or leave it alone!
- Replace text with other text or use Regular Expressions.
- Add a fixed prefix or suffix.
- Add text to a specific position to the filename.
- Remove the first n characters.
- Remove the last n characters.
- Remove from the nth character to the nth character.
- Remove a list of characters.
- Remove a list of words.
- Remove all digits, characters or symbols.
- Remove double-spaces.
- Change filename to upper case, lower case, camelCase - all with user-defined exceptions.
- Auto-number files, with a prefix or suffix, and with a predefined minimum-length if required.
- Rename files according to a delimited list.
- Rename files according to user-defined callback.
- Renaming from a previusly created TXT File.
- The ability to restore the renamed files to their original names.
How it works
Have a look at this simple usage example for better understanding of how the class works.
- You provide BatchFileRename with a directory to rename its contents.
- If you do not want to rename all the files within the directory, you provide BatchFileRename with some rules to filter undesired files from being renamed like a file extension or a regular expression pattern.
- You provide BatchFileRename with some rules according which the files will be renamed.
- BatchFileRename walks through the selected files and renames it individualy according to the renaming rules you already set.
- Then, BatchFileRename provides you with a list of the successfully renamed files and the files that were not renamed as a result of such error.