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 folder containing multiple files with names like:


I want to place an extension at the end of the filename so that the new filename looks like:


I tried using ren *. *.txt, but it did not work. How can I do this?

share|improve this question
You could possibly use a FOR loop. – user3463 Aug 14 '12 at 0:14
Does "REN * .TXT" work? The wildcard "/." would imply any filename that ends in a period. I can't try it on this PC, but I seem to remember it working in XP. – hdhondt Aug 14 '12 at 3:45
Does "REN star star.TXT" work? The wildcard "star." would imply any filename that ends in a period. I can't try it on this PC, but I seem to remember it working in XP. Sorry for the "star"s as I cannot figure out any other way to prevent it from turning into italics – hdhondt Aug 14 '12 at 3:50
@hdhondt Enclose it in backticks to indicate an inline code block (`<code goes here>`). If you ever want to use an asterisk in normal text, insert a backslash before it: \*hello\* so you can have something like this: *hello* – Bob Aug 15 '12 at 3:06

According to this page you could try running these commands in powershell (search for it in the windows start menu):

cd "\path\to\dir"
Dir | rename-item -newname  { $_.Name +".jpg" }
share|improve this answer
Thanks for the edit. I've changed my vote. – user3463 Aug 15 '12 at 23:41

Bulkrename can do it, first "remove" the extension, hit rename then hit reset, then add the one you want using the "extra" function. You can do this for multiple files in the same folder.

. enter image description here


enter image description here

share|improve this answer

A single command line command will do the trick:

for /f "tokens=*" %a in ('dir /b') do @ren "%a" "%a.txt"

Just change into the folder with the files.

share|improve this answer
@nandha kumar asks: Thank you Multiverse IT. Please explain your command. – fixer1234 Aug 17 '15 at 15:51

Can do it easily with PowerShell.

Get-ChildItem -Path C:\Directory | ? {!$_.PSIsContainer} | % {Rename-Item -LiteralPath $_.Name -NewName ($_.Name + ".txt")}`
share|improve this answer

Here's the way to do it with JP Software's TCC, a command interpreter whose REN command supports regular expressions:

ren ::(.*) ::\1.txt

Without regular expressions, it's still a one-liner. TCC supports the same FOR syntax as Microsoft's cmd, so one could use the FOR one-liner from Multiverse IT's answer.

With all of the command-line answers here, by the way, note that it's important that scanning the directory precede any rename operations if possible. You weren't specific enough in your question about the original filenames, so in our answers we've had to assume that every file is to be processed. The search wildcards will therefore match the resultant filenames as well, ending up with files potentially being renamed multiple times, if one isn't careful.

If one knew that the source filenames only contained one dot, say, then one could construct a more restrictive search wildcard that didn't match the resultant filenames that have two dots. Using the non-regular expression form of TCC's ren command this would be:

ren *.*. *.*.txt

The trailing dot in the search wildcard is important. (. is actually a metacharacter in search wildcards, although very few people document it. It matches either a . or the end of a name.) It matches the ends of the names, and prevents the preceding * from matching a dot.

Further reading

  • JP Software. REN. Take Command / TCC Help.
  • JP Software. FOR. Take Command / TCC Help.
share|improve this answer

You must log in to answer this question.

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