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.
- JP Software. REN. Take Command / TCC Help.
- JP Software. FOR. Take Command / TCC Help.