coppermine-gallery.com/forum

Support => cpg1.6.x Support => cpg1.6 plugins => Topic started by: Chris99 on August 03, 2026, 08:02:42 PM

Title: serch for a "userpics to subdir" plugin
Post by: Chris99 on August 03, 2026, 08:02:42 PM
Hi,
 I searching for a plugin "userpics to subdir" which creates a subdir in Userpics Folder and move the files in the subdir. 

I have that same problem like in 2015. too much files in Userpics Directory:
André creates a script:
https://coppermine-gallery.com/forum/index.php/topic,78004.0.html

Will this work with the 1.6 Coppermine?

Thank you.
Title: Re: serch for a "userpics to subdir" plugin
Post by: ron4mac on August 03, 2026, 10:37:57 PM
This may be what you are looking for ... https://coppermine-gallery.com/forum/index.php/topic,79117.0.html
Title: Re: serch for a "userpics to subdir" plugin
Post by: Chris99 on August 04, 2026, 10:54:28 AM
Hi, thank you. Ive tried this tool, but it seems there are too many files (500.000) in userpics folder. I get a white page and nothing happens.... neither after 30 min...


Andre wrote this tool, it works perfect in those days with 1.5, does it work also with 1.6?

Thank you.
 
<?php
define
('IN_COPPERMINE'true);
define('DB_INPUT_PHP'true);
require(
'include/init.inc.php');

if (!
GALLERY_ADMIN_MODE) {
    
cpg_die(ERROR$lang_errors['access_denied']);
}

$limit 50;
$result cpg_db_query("SELECT pid, aid, filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE filepath LIKE '{$CONFIG['userpics']}%' AND filepath NOT LIKE CONCAT('%/', aid, '/') LIMIT $limit");

if (
mysql_num_rows($result)) {
    
pageheader('Moving''<meta http-equiv="refresh" content="1; URL='.$CPG_PHP_SELF.'">');
    echo 
'<table width="100%"><tr><td class="tableh1" width="50%">File</td><td class="tableh1" width="50%">Moved to</td></tr>';
} else {
    
pageheader('Done');
    echo 
'<table width="100%"><tr><td>Done.</td></tr>';
}

while (
$row mysql_fetch_assoc($result)) {
    
$dest_dir_sql $row['filepath'].$row['aid'].'/';
    
$dest_dir $CONFIG['fullpath'].$dest_dir_sql;
    
$src_dir $CONFIG['fullpath'].$row['filepath'];
    
$images = array($row['filename'], $CONFIG['normal_pfx'].$row['filename'], $CONFIG['thumb_pfx'].$row['filename'], $CONFIG['orig_pfx'].$row['filename']);

    if (!
is_dir($dest_dir)) {
        
mkdir($dest_diroctdec($CONFIG['default_dir_mode']));
        if (!
is_dir($dest_dir)) {
            
cpg_die(CRITICAL_ERRORsprintf($lang_db_input_php['err_mkdir'], $dest_dir), __FILE____LINE__);
        }
        @
chmod($dest_diroctdec($CONFIG['default_dir_mode'])); //silence the output in case chmod is disabled
        
$fp fopen($dest_dir '/index.php''w');
        
fwrite($fp' ');
        
fclose($fp);
    }

    foreach (
$images as $image) {
        if (!
file_exists($src_dir.$image)) {
            continue;
        }
        if (!
rename($src_dir.$image$dest_dir.$image)) {
            
cpg_die(CRITICAL_ERRORsprintf($lang_db_input_php['err_move'], $src_dir.$image$dest_dir), __FILE____LINE__);
        } else {
            echo 
'<tr><td>'.$src_dir.$image.'</td><td>'.$dest_dir.'</td></tr>';
        }
    }

    
cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET filepath = '$dest_dir_sql' WHERE pid = {$row['pid']}");
}

echo 
'</table>';
pagefooter();
Title: Re: serch for a "userpics to subdir" plugin
Post by: ron4mac on August 04, 2026, 08:23:27 PM
That would have to be modified to work with CPG 1.6
I've modified a copy of the FileMove plugin to work with only 250 files at a time. Maybe that can work for you. ( I have no way to fully test it )