hav0k
Sep 18th 2007, 8:20 pm
I'm getting really stuck here...
I have a list of files that I read from a folder:
thumb.Aaliyah-1.jpg
thumb.Aaliyah-22.jpg
thumb.Aaliyah-3.jpg
thumb.Abi-Titmuss-1.jpg
thumb.Abi-Titmuss-2.jpg
thumb.Abi-Titmuss-3.jpg
thumb.Ada-Nicodemou-6.jpg
thumb.Ada-Nicodemou-7.jpg
thumb.Adele-Silva-3.jpg
thumb.Adele-Silva-4.jpg
thumb.Adriana-Karembeu-1.jpg
I want to take the middle name, ex. Aaliyah or Ada-Nicodemou, and create a folder from that name. Then I want to move all related thumnails to that created folder. So far I was able to list the names only but if the names has 2 digits, ex Aaliyah-22, is outputs Aaliyah- since I'm using preset amount of characters to remove using the substr() function.
So I was able to finally get the following list after trying many ways:
Aaliyah
Aaliyah-
Aaliyah
Abi-Titmuss
Abi-Titmuss
Abi-Titmuss
Ada-Nicodemou
Ada-Nicodemou
Adele-Silva
Adele-Silva
Adriana-Karembeu
You can see that "Aaliyah-" problem I mentioned earlier. So now I've come to a block and need some input about how to continue forward to reach my goal wrote about up above.
Thanks!
Here's the code I have so far:
<?php
$dir = 'C:\wamp\www\filesorter\thumbs';
$dir_handle = @opendir($dir) or die("Unable to open $dir");
$clist = array();
while (false !== ($file = readdir($dir_handle)))
{
if($file!="." && $file!=".." && $file!="Thumbs.db" && $file!="Thumbs.")
$clist[$file] = $file;
}
closedir($dir_handle);
sort($clist);
foreach ($clist as $key => $file1) {
$rfile = str_replace("thumb.","",$file1);
$refile = str_replace(".jpg","",$rfile);
$dirname = substr("$refile", 0, -2);
echo "$dirname<br />";
}
?>
I have a list of files that I read from a folder:
thumb.Aaliyah-1.jpg
thumb.Aaliyah-22.jpg
thumb.Aaliyah-3.jpg
thumb.Abi-Titmuss-1.jpg
thumb.Abi-Titmuss-2.jpg
thumb.Abi-Titmuss-3.jpg
thumb.Ada-Nicodemou-6.jpg
thumb.Ada-Nicodemou-7.jpg
thumb.Adele-Silva-3.jpg
thumb.Adele-Silva-4.jpg
thumb.Adriana-Karembeu-1.jpg
I want to take the middle name, ex. Aaliyah or Ada-Nicodemou, and create a folder from that name. Then I want to move all related thumnails to that created folder. So far I was able to list the names only but if the names has 2 digits, ex Aaliyah-22, is outputs Aaliyah- since I'm using preset amount of characters to remove using the substr() function.
So I was able to finally get the following list after trying many ways:
Aaliyah
Aaliyah-
Aaliyah
Abi-Titmuss
Abi-Titmuss
Abi-Titmuss
Ada-Nicodemou
Ada-Nicodemou
Adele-Silva
Adele-Silva
Adriana-Karembeu
You can see that "Aaliyah-" problem I mentioned earlier. So now I've come to a block and need some input about how to continue forward to reach my goal wrote about up above.
Thanks!
Here's the code I have so far:
<?php
$dir = 'C:\wamp\www\filesorter\thumbs';
$dir_handle = @opendir($dir) or die("Unable to open $dir");
$clist = array();
while (false !== ($file = readdir($dir_handle)))
{
if($file!="." && $file!=".." && $file!="Thumbs.db" && $file!="Thumbs.")
$clist[$file] = $file;
}
closedir($dir_handle);
sort($clist);
foreach ($clist as $key => $file1) {
$rfile = str_replace("thumb.","",$file1);
$refile = str_replace(".jpg","",$rfile);
$dirname = substr("$refile", 0, -2);
echo "$dirname<br />";
}
?>