title: How to rename file(1).ext to file1.ext in php
body: <p>I want to convert pdf files into text files using xpdf converter with php.
  The problem is the file names are file(1).pdf,file(2).pdf...The brackets are the problem.XPDF cannot read file names with brackets.So i want to change the name to file1.pdf,file2.pdf....(remove brackets)
  I tried to use rename() in php in every possible way with escaping but still get either of two errors</p>
  
  <p>=System cannot find the path code 2
  =Directory,file,volume syntax is wrong or something... code 123</p>
  
  <p>Please somebody help me.I want to do it in PHP itself.</p>
  
  <p>what i used is..</p>
  
  <pre><code>for($i=1;$i&lt;=$_POST['number'];$i++)
  {
  
      $filen2="\"d:/res/file(".$i.").pdf\"";
      $file="\"d:/res/files".$i.".pdf\"";
      rename($filen2,$file);
      echo "converting file ".$filen2."&lt;br/&gt;";
      shell_exec("D:/xpdf/bin32/pdftotext.exe $file");
  
  } 
  </code></pre>
  
  <p>and...</p>
  
  <pre><code>for($i=1;$i&lt;=$_POST['number'];$i++)
  {
  
      $filen2="\"d:\\res\\file(".$i.").pdf\"";
      $file="\"d:\\res\\files".$i.".pdf\"";
      rename($filen2,$file);
      echo "converting file ".$filen2."&lt;br/&gt;";
      shell_exec("D:/xpdf/bin32/pdftotext.exe $filen2");
  
  } 
  </code></pre>
  
  <p>right now i tried rename() on files without brackets...still it doesnt work...what could be wrong??XPDF worked for files without bracket without any problem</p>