Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 list of files which are in the format on the left. I want to append a string to each file name, but before the extension, as shown:

File 1.txt  ->  File 1 version 1.txt
File 2.txt  ->  File 2 version 1.txt
File 3.txt  ->  File 3 version 1.txt
File 4.txt  ->  File 4 version 1.txt

In each case, the appended string is the same across all files.

This seems like such a simple task, but I'm having some trouble putting this into a batch file.

I've tried the ren command and followed some the the examples on this page, but the resulting file names append the string after the extension:

File 1.txt version 1.txt
share|improve this question
The info at your SS64 "this page" link comes from this SU Q&A (with my blessing): How does the Windows RENAME command interpret wildcards? I maintain the SU answer (infrequently) as I discover new features. – dbenham Jun 5 '13 at 13:58
up vote 6 down vote accepted

for longer filenames you will have to add some more ? in the block with the mass of ?????????

ren *.?* ????????????????????????????????????????????????????????" version 1".*
share|improve this answer
Thanks for answering so promptly! I edited the command slightly, to retain the file extension, and to only affect txt files: ren *.txt ?????????????????????????" Version 1.txt" – TheTurkey Jun 5 '13 at 11:13
what if I want to append something at the beginning – farhana haque Aug 5 '15 at 6:25

Instead of relying on ren's undocumented quirks, why not do this the proper way?

for %a in (*.txt) do ren "%~a" "%~na version 1%~xa"

If you want to use this in a batch file just remember to double each % sign.

share|improve this answer
Excellent! this is a better answer any day. +1 – Fr0zenFyr Jul 24 '14 at 10:05

I wanted to add "_A" to multiple files and this is how I did it.

I removed the extension first, added the suffix, then changed extension back to original. It sure did work for me and kept the batch code simple, as I am not much of a programmer.


REN *.pdf *.
REN *. *_A.
REN *. *.pdf
share|improve this answer

For the folks who are inexperienced with command (like me), there are a couple of softwares that make bulk rename very easy:

  • Bulk rename utility (no open source)
  • Rename-It! (open source)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.