totem/files-renamer

使用给定的重命名函数在目录中重命名文件。

1.0.0 2016-12-18 15:05 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:52:51 UTC


README

使用给定的重命名函数在目录中重命名文件。

安装

安装的最佳方式是下载最新版本或使用Composer。

php composer.phar require --dev totem/files-renamer

FileRenamer需要PHP 7.0.0或更高版本。

基本用法

// We want to delete numbers from the file names.
$renamer = new FilesRenamer(
	__DIR__ . '/files',
	function ($fileName) {
		return preg_replace('/\d*/', '', $fileName);
	}
);

// We will also rename the files in the subdirectories.
$renamer->setRecursiveMode(true);

// We will first test if the result is correct.
$renamer->setDebugMode(true);

$renamer->run();