I solved the problem.Actually the problem was with my Windows.There was a f***** virus in it which prevented me from accessing advaned operations like changing PATH variable,opening control panel etc...Now i reinstalld Windows and every thing works just as expected..
The syntax of rename() is rename(<path to file>,<path to the same file with new name>);
for example to rename D:\res\file(1).pdf
to file1.pdf
i used the following code rename('D:/res/file(1).pdf','D:/res/file1.pdf');
.It worked perfectly well. I also tried rename('D:\\res\\file(1).pdf','D:\\res\\file1.pdf');
it also worked well.Wish I had reinstalled Windows earlier.