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 directory that contains about 3000 images, what I would like to do is to print out (to a file if possible or even to screen) the whole images names after doing some string formatting and concatenation to them,
for example:

I would like each image name to be transformed into the following formula

tick.png  -->> <image src="tick.png" />


share|improve this question
Are we talking real MS-DOS or just command-line? – Bobby Feb 2 '11 at 10:03
sorry it's Command prompt (the one that you can run it by typing 'cmd' in the run dialog), What's the difference between Command prompt and MS-DOS ? – Anas Nakawa Feb 2 '11 at 10:07
That the command prompt is a command-line mimicking the behavior of the Operating System called MS-DOS. – Bobby Feb 2 '11 at 10:16
CMD.EXE is a 32-bit (or 64-bit) command processor that supports MS-DOS commands. MSDOS ( is 16-bit and a different beast. – Alan B Feb 2 '11 at 10:57
up vote 4 down vote accepted

What I suggest you to do is to write a simple batch file that processes files in the directory and outputs them in the given format.

For instance create file run.bat and type the following command in it:

FOR %%F IN (*.png) DO @echo ^<img src='%%F'/^>

Now, you can run the command in the command-line, by entering:


If you want to save the results of the batch process into a file (such as images.html), you can use:

run > images.html

If you need to add more commands/processing steps, just edit the batch file.

For a good reference on commands (such has FOR loops), see Programming CMD on Wikibooks. Note that for complicated batch tasks, command-line interpreter may not be sufficient. For more complex batch programming, I encourage you to learn a real scripting language like Python.

share|improve this answer
Nice! I've done something better with Windows right click option on folder to create an image viewer in a html file. I love Dos batch! – kokbira Feb 2 '11 at 11:45

There you go:

for %f in (*.png) do echo ^<img src="%f" /^> >> myFileList.txt


for %f in (*.png) do <command>

A simple loop for all files in the current directory which match *.png.

echo ^<img src="%f" /^> >> myFileList.txt

Echo the string into the file (redirect output via >>, this will append to the file. > will truncate the file). ^ is need to escape the <.

share|improve this answer

You must log in to answer this question.

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