Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few folders with hundreds of html files. The file name should have been .htm but it is .asp.htm and it does not run. It is plain html file and there is no asp code.

So, I tried to rename the files using rename command. I tried like this

rename *.asp.htm *.htm

But it does not work. After trying a few other combinations I believe rename or ren command can't change the double dot extension. The only change the last extension. So, if I try

rename *.asp.htm *.asp.htm

I thought nothing would be changed, but, the file name changes from file.asp.htm to file.asp.asp.htm

I hope someone would help me with this. Another thing is, can I force apache to run files with .asp.htm extension? Currently it can't run those files.

Thanks in advance.

share|improve this question
up vote 2 down vote accepted

ren *.htm *. will change all .asp.htm to just .asp

for /f "delims=." %f in ('dir /b *.htm') do @ren "%~f.asp.htm" "%~f.htm" will change all .asp.htm to just .htm

share|improve this answer
this is linux that is windows – saber tabatabaee yazdi Oct 31 '12 at 4:49
This is what I was looking for. Thanks a lot. – sakibmoon Oct 31 '12 at 4:53
You're welcome, sakib! @saber: sakib added the Windows-7 tag and so I provided a Windows 7 command. It is not a Linux shell command. Type for /? in Windows to learn all its advanced options. – Karan Oct 31 '12 at 4:59
thanks , i guess this seems to appear as linux command but this is work. i have'nt scripting skills. can you teach me? – saber tabatabaee yazdi Oct 31 '12 at 5:04
@saber: This is not the proper site for tutorials, but if you want to learn check out the command-line help (type any command and then /?), and also check out this great site. – Karan Oct 31 '12 at 5:12

with Total Commander and Servant Salamander tools try it.

or Rename-File-Extensions

with ??? doesn't solve this problem

rename *.php.htm *.htm

rename *.php.??? *.htm

rename *.php.??? *.php.htm

rename *.??? *.php

rename *.??? *.htm

rename *.php *.htm
share|improve this answer
I don't want to change it to .asp.asp, I want to make it .htm. This version doesn't work. Thanks anyway. – sakibmoon Oct 31 '12 at 4:44
some kind of tools here that solve your problem in windows – saber tabatabaee yazdi Oct 31 '12 at 4:50
Thanks, but I can do it with just two commands. That's faster. – sakibmoon Oct 31 '12 at 4:55
scripting is good skill that we have to learnit – saber tabatabaee yazdi Oct 31 '12 at 5:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .