Re: renamed images are now corrupt...

From: Date: Fri, 27 Feb 2004 00:27:15 +0000
Subject: Re: renamed images are now corrupt...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-178973@lists.php.net to get a copy of this message
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 <mike@saturn5.com> 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/

« previous php.general (#178973) next »