How mass rename files in Windows 7

I recently recovered and cleaned some data that was infected with a version of cryptolocker. Now all of my files are as follows:


All the files are definitely clean and open up without issue, but the names are confusing my client.

Is there a way to remove only the .exe from the filenames on a mass scale?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
- All filenames have name format: filename.ext.ext

Assuming you have of files.txt containing the names of your files:

IMPORTANT: For visual confirmation, this code has an ECHO prefixing REN. To run it for real, remove the ECHO prefix.


Open in new window

Make a .bat file of this:

for /f %%a in (files.txt) do (
  for /f "tokens=1-9 delims=." %%A in ("%%a") do (
    ECHO ren "%%~a" "%%A.%%C"

Open in new window

Update: This version creates files.txt, which reads the filenames from a folder. Just change SrcDir variable to your needs:
set SrcDir=c:\folder

dir /s /b "%SrcDir%">files.txt

for /f %%a in (files.txt) do (
  for /f "tokens=1-9 delims=." %%A in ("%%a") do (
    ECHO ren "%%~a" "%%A.%%C"

Open in new window

There is a free program call BulkRenameUtility available from

It is very powerful and has plenty of options. It even gives you a preview of what is going to change before you commit so you can be certain you have everything right.
EirmanChief Operations ManagerCommented:
Flash Renamer is I believe the best renamer you can get.
Try a 30 day trial. There are no limits during the trial.
SETTINGS For Deleting Last 4 Characters Of FilenamesIn the above settings, it is set to remove four characters from the filename counting backwards from the end.
At the top, note that the file extension is not selected (nor folders) for processing ..... just the filename.
Look at the preview on the right.

Important:  you can UNDO a batch rename.

At the moment, all files in W: will be processed, but it is easy to manually select (or filter for) chosen files.

It's a superb program - If you try it, I'll bet you buy it!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Excellent suggestion Eirman.  For $19.95, £13.09, or 17.72 Euros, that's an impressive program.  I do like the fact that "you can UNDO a batch rename", which is something that is most often missing in free and paid-for programs, and is a worry to people when using command line batch files or scripts.  I might buy it myself.
PcdynamixAuthor Commented:
Thanks Eirman, Exactly what I was looking for. Very powerful.
EirmanChief Operations ManagerCommented:
Thanks Pcdynamix. Some useful tips:

You can select the files to be processed from Windows Explorer, then
Right click and select .... Flash Renamer > Start & Load Selected Files from the context sensitive menu.
If you choose to process sub-folders, all the files will be listed in a flat-file structure
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 7

From novice to tech pro — start learning today.