Hi,
anyone know if it possible to batch renaming the images when create a new album?
I.e.
1) I create a new album called "My new album", the automatic folder name will be "my-new-album"
2) I upload "image1.jpg", "another_image.jpg" and "the_last_image.jpg"
3) The 3 images batch renamed to "my-new-album-001.jpg", "my-new-album-002.jpg" and "my-new-album-003.jpg"
Anyone can help me to do this?
Comments
Now I'm working on a pclzip function to do that.
With this hack when a user create a new album and upload a zip all the images of the zip will be renamed in this way:
{folder_name}-{xxx}.{extension}
where xxx is a progressive number (i.e. 001, 002,etc)
Then if i create a new album called "My new album" the images will be renamed as:
my-new-album-001.jpg
my-new-album-002.jpg
my-new-album-003.jpg
my-new-album-004.jpg
and so on.
If anyone is interested:
in zen/functions.php find
---
// Use Zlib
require_once('pclzip.lib.php');
$zip = new PclZip($file);
if ($zip->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
die("Error : ".$zip->errorInfo(true));
}
---
After add:
---
// Begin batch-renaming hack
$batch_name = $_POST['folder'];
$ls = glob($dir."/*");
$n = 1;
foreach ($ls as $image_tmp_name) {
$nn = str_pad($n,3,'0',STR_PAD_LEFT);
$file_temp1 = explode($dir,$image_tmp_name);
$file_temp2 = explode('.',$file_temp1[1]);
$file_ext = $file_temp2[1];
rename($image_tmp_name, $dir.'/'.$batch_name.'-'.$nn.'.'.$file_ext);
$n++;
}
// End batch-renaming hack
---