Jump to content

[SOLVED] how to add an extension to a file that is without extension.


xpace

Recommended Posts

Well I don't know about that, but I can tell you one thing, it's a simple task you want to do...consider making a simple batch file / bash script for it instead, that will be easier way to do it, unless there's some specific reason behind doing it from php...

thanks guys,

 

dhruvasagar -> if you know how to create the bash file, I would appreciate it, I don't really care what way it is going to be done, I just thought that PHP would handle such a task and I'm pretty familiar with PHP that's why I was asking about PHP.

 

Vijay -> if I had few pictures I would do it manually, but I have more than 200 of them and that's too much. I'm not sure what you mean by using imagefunction.

 

thanks

I have solved the problem - here it is >

 

<?php

   $mydir = dir('imgs');
   
   while(($file = $mydir->read()) !== false) {
      if(is_dir($mydir->path.$file)) {
         echo "Directory: ".$file."<BR>";
      } else {
         $new = "image/".$file.".jpg";
         echo $file." = ".$new."<br>";
      	 rename($mydir->path."/".$file, $new);
      }
   }
   $mydir->close();

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.