Jump to content

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


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

anyone else please ?

 

I have tried rename already but it doesn't want to add the extension as it looks only for the name itself not the extension (that's what I think)

nothing happened after rename with my files,

 

thank you

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();

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.