note 104942 added to function.readdir

From: Date: Sun, 17 Jul 2011 18:49:23 +0000
Subject: note 104942 added to function.readdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-181629@lists.php.net to get a copy of this message
## List and Rename all files on recursive directories with "recursive directory name" as template + counter ## Advice: other files in the same directory will result in a warning <?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "opendir6.php") { echo "$file"; echo "<br>"; $count = -1; $handle2 = opendir($file); while (false !== ($file2 = @readdir($handle2))) { echo "$file2"; if ($count <10 ){ @rename("$file/$file2", "$file/$file"."_0"."$count".'.jpg');} else { @rename("$file/$file2", "$file/$file"."_"."$count".'.jpg');} echo "<br>"; $count = $count + 1; } echo "<br>"; } } closedir($handle); } ?> ---- Server IP: 81.88.49.26 Probable Submitter: 79.56.22.30 ---- Manual Page -- http://www.php.net/manual/en/function.readdir.php Edit -- https://master.php.net/note/edit/104942 Del: integrated -- https://master.php.net/note/delete/104942/integrated Del: useless -- https://master.php.net/note/delete/104942/useless Del: bad code -- https://master.php.net/note/delete/104942/bad+code Del: spam -- https://master.php.net/note/delete/104942/spam Del: non-english -- https://master.php.net/note/delete/104942/non-english Del: in docs -- https://master.php.net/note/delete/104942/in+docs Del: other reasons-- https://master.php.net/note/delete/104942 Reject -- https://master.php.net/note/reject/104942 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181629) next »