Here is the script I used to rename images.




<?php
clearstatcache();
$filename = "product_tn.txt";
$imgs = (array) null;
$tmp = (array) null;
$config = file($filename);
reset ($config);
$handle = fopen("import_product_tn.txt", "w");
$write = "";

foreach ($config as $line) {
     if ( $line == "" ) next($config);
     elseif ( $line == "\n" ) next($config);
     elseif ( strstr($line,"#")) next($config);
     else {
         $value = split(Chr(9),$line);
         $imgs[$value[0]] = $value[1];
         }
     }

foreach ($imgs as $k => $v) {
if ((strpos($v,'/s.gif') === FALSE) AND (strpos($v,'noimage') === FALSE) AND (strlen(trim($v)) >= 0)) {
$tmp = split("/",$v);
$cnt = count($tmp);
$cnt = $cnt - 1;
$re = explode(".", $tmp[$cnt]);
$ext = $re[1];
$renamed = strtolower($k).".".strtolower($ext);
if (file_exists("Merchant2/".trim($v)) AND $cnt) {
rename("Merchant2/".trim($v), "pi/".$renamed);
$write .= $k.Chr(9)."graphics/00000001/".$renamed.Chr(10);
} else {
$write .= $k.Chr(9).Chr(10);
echo $k."<br>";
}
} else {
$write .= $k.Chr(9).Chr(10);
}
}


fwrite($handle, $write);
fclose($handle);
clearstatcache();
?>


On Thu, 26 Feb 2004 16:21:55 -0800 (PST), Michal Migurski <[EMAIL PROTECTED]> wrote:


I wrote a small script to rename a few thousand images, both gif and
jpeg... After running the script, none of the renamed images can be
viewed or downloaded.

I now have over 3000 images I cannot download or view on our website.
What about rename caused this?

Well, on line 5 of your script... oh wait. /Where's your script?/


---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html



-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to