PHP code example of nsrosenqvist / phulp-rename
1. Go to this page and download the library: Download nsrosenqvist/phulp-rename library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nsrosenqvist / phulp-rename example snippets
use NSRosenqvist\Phulp\Rename;
$phulp->task('images', function($phulp) {
// By Array
$phulp->src(['assets/images/'], '/JPG$/')
->pipe(new Rename([
'prefix' => 'camera-',
'suffix' => '2018',
'extension' => 'jpg',
// Other editable keys:
// - filename
// - dirname
]))
->pipe($phulp->dest('dist/images/'));
// By function
$phulp->src(['assets/images/'], '/jpg$/')
->pipe(new Rename(function($name) {
$name['prefix'] = 'image-';
$name['filename'] = md5($name['filename']);
return $name;
}))
->pipe($phulp->dest('dist/images/'));
});