Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Renaming multiple files in multiple directories using ms-DOS

Posted on 2005-02-24
Medium Priority
Last Modified: 2008-01-09
I would like to change multiple .asp file extensions to .html.

I have thousands of files and many directories. I would like to change all the .asp file extensions in the entire site at once.

I know you can use the ren command in ms-dos to rename all  files in the directory (i.e. ren "*.asp" "*.html") but this  only works in one directory. How can I have it rename files in subdirectories and sub-subdirectories too?
Question by:crchambers
  • 2
LVL 35

Assisted Solution

by:Nirmal Sharma
Nirmal Sharma earned 180 total points
ID: 13400025
did you try /s switch with rename ?
LVL 35

Assisted Solution

by:Nirmal Sharma
Nirmal Sharma earned 180 total points
ID: 13400031
See if this can help you: -

LVL 97

Accepted Solution

Lee W, MVP earned 195 total points
ID: 13400313
This has to be scripted.  there is no /s script for the ren/rename command.  BUT, the script is easy and simple - see below:

The following script will rename everything .asp to everything .html AND make a log of it in rename.log from the directory it's executed in.  It WON'T process the current directory.  For example, to process the IIS default web tree, execute the command in c:\inetpub\wwwroot (just remember it does not process c:\inetpub\wwwroot itself).
@echo off
for /f "tokens=1 delims=" %%a in ('dir /s /b /ad') do if exist "%%a\*.asp" ren "%%a\*.asp" *.html & echo ren "%%a\*.asp" *.html >> rename.log

With the same restrictions as the above script, this one just creates another batch file you can review and then execute.  The batch file it creates is called rename.cmd

@echo off
for /f "tokens=1 delims=" %%a in ('dir /s /b /ad') do if exist "%%a\*.asp" echo ren "%%a\*.asp" *.html >> rename.cmd

Author Comment

ID: 13643558
I ended up just doing it the old-fashioned way.... manually. Thanks for everybody's input.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like 192.168.xxx.1, I've seen routers with default values of:,,, …
We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question