Change File Extension Script

Change file extension script is used to you can change file format extension through drop down list.

Demo :

Following Test folder have 4 file available.

Example :

In the above drop down list is used to select file extension and if you click change button the ask pop up message "Are you sure want to change this file format?" the you will click ok button immediately will change all file format at Test folder other wise will not change test folder.

Code :

Following code is use to Change File Extension Script if you need code to copy and use to your website.

  $dir = 'test'; //directory name
  $newExt = "asc"; //New extesion type
  $oldExt = "txt"; //Old extesion type
  foreach (glob("$dir/*.$oldExt") as $file)
  $name = substr($file, 0, strrpos($file, "."));
  rename ($file, "$name.$newExt") or die ("Cannot rename file '$file'!");
  echo "$count file(s) renamed.";

In the above $dir variable is used to assign directory name and $newExt variable is used to assign to new file format extension type and $oldExt variable is used to assign the old file format type.substr() function is used to divide string for this functions and rename() function is used to rename old file extension to new file extension.

Free Download Script :

If you need to Change File Extension Script click and download from following link.