Member
Member
Pennywise83   2008-05-03, 13:24
#1

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?

Member
Member
aitf311   2008-05-03, 14:10
#2

Why don't you do the batch rename process before you upload them? http://www.freedownloadscenter.com/Utilities/File_Cleanup_Utilities/Batch_File_Renamer.html

Member
Member
macalter   2008-05-03, 14:28
#3

ZP cannot do renaming. It must be done using 3rd party PC or Mac application.

Member
Member
Pennywise83   2008-05-03, 14:36
#4

I want this feature to skip the process with a 3rd party application.
Now I'm working on a pclzip function to do that.

Member
Member
Pennywise83   2008-05-03, 15:57
#5

I've done!
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

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.