Hello!
I need some code that outputs all files in a directory and the number of files.
e.g. /home/images/
then it out puts maybe an array or something like array[1]=car.jpg, array[2]=flower.gif, array[3]=ABC-123.jpg etc.
It is to get all the names and take out all the non alphanumeric charactors (e.g. -_) so summat like this (psudo code):
$directory = "/home/images";
$files = get (files in dir $directory);
$numberoffiles = quantity($files);
while($i<$numberoffiles){
$i = $i + 1;
$file_name = ereg_replace("[^A-Za-z0-9.]", "", $files[i]);
$file_name = $file_name.".jpg";
if(file_exists("$directory/$file_name")) {
}else{
rename("$directory/$files[i]", "$directory/$file_name");
}
}
something like that!
BUT I OBVIOUSLY DONGT WANT THE DOT (.) DELETEING BEFORE THE jpg, gif etc!!!!
Any ideas?? thanks!