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

What I'd like to achieve in the end is to generate a text file that lists all *.txt files in the current directory with the path appended to the beginning of the filenames, and some other string after the filenames.


C:\path\first.txt string

C:\path\second.txt string

C:\path\third.txt string

As of now all I can think of is to use

dir /b *.txt

and some sort of regex code to append the strings, but unsure how to. If it matters, the path and string at the end are the same for all lines.

Thank you!

share|improve this question
up vote 1 down vote accepted

Create a batch file e.g:


@echo off
for %%i In (*.txt) DO echo %CD%\%%i string

then simply run script.bat from the directory where you want to list the files and append the string

share|improve this answer
That works. Thank you! – csg Sep 6 '13 at 20:59

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.