You are here: Re: rename function not working ??? « PHP Programming Language « IT news, forums, messages
Re: rename function not working ???

Posted by Jerry Stuckle on 02/23/06 21:35

Yannick Benoit wrote:
> Hi guys.
> I have like hundreds of pictures in a folder
> and then I use this function to rename them
> all to a following number. but very often I
> noticed that some pictures get lost and I
> dont know where ? anyone can tell me
> whats wrong ?
>
> $dir = getcwd()."/dump/";
> $dh = opendir($dir);
> while (false !== ($filename = readdir($dh))) {
> if(($filename <> ".")&&($filename <> "..")){
> $pic_ctr++;
> rename("dump/".$filename, "dump/".$pic_ctr.".jpg");
> }
> }
>
> thanx for your help !
>
>

Do some of the files already have numbers? If you try to rename a file,
to, i.e. 2.jpg and there already is a 2.jpg, the rename will fail.

Also, as others have pointed out - did you initialize $pic_ctr before
using it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация