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

How to copy a list of file names to text file?

I am linking the above page because of its relevance to my question.

Is there anything similar that can be done to output a 'plain' looking text file (or XML or CSV file) with basically the same data that the following CMD prompt produces:

dir > c:\list.txt

However, the only difference I need is the run-time of any and all video files included in the outputted file. Can this easily be done?

Can this be done in the Python terminal or Microsoft's DOS prompt?

share|improve this question
type a.csv <-- is that what you want? – barlop Sep 2 '12 at 19:26
But the "dir > c:\jjj.txt" doesn't tell me the video's length. And this may pose another problem but my videos are of all different extentions: .mp4 .avi .mkv etc... I do not know what kind of problems that will bring upon me... – 1337475 Sep 2 '12 at 20:10

old answer
copy /B file1+file2 file3

revised answer

Use mediainfo , download it. Here is the command line version.

C:\>mediainfo file.wmv | find "Duration"
Duration                                 : 14mn 3s
Duration                                 : 14mn 3s
Duration                                 : 14mn 3s

You can also do | find "name" and get the name.

You could just grab the first line, so | head -n 1 (head requires gnuwin32), and you could just grab the 14mn 3s

C:\>for /f "tokens=1-2,*" %f in ('mediainfo "a.wmv" ^| find "Duration"')
 do @echo %h
14mn 3s
14mn 3s
14mn 3s

You can redirect to a file.

If you put this bat file into the same directory as your videos

Here i've used the head command from gnuwin32. but if you remove | head -n 1, you'll still get the idea.


for %%f in (*.*) do (
echo %%f >>y
 mediainfo %%f | find "Duration" | head -n 1 >>y
echo. >>y

C:\>type y

Duration                                 : 30s 0ms

Duration                                 : 45s 11ms
share|improve this answer
you can try type, type a.a b.b >c.c That might work but it's possible type will change stuff so check the file size of the final file. It might work. But copy/b will definitely do it fine. this says… "In general, avoid using the type command to display binary files." but it may be ok i haven't tested it enough. – barlop Sep 2 '12 at 19:38
I think you may be mistaken... That made a copy of the video file. I'm looking for the creation of a text document listing the video length or run time of said video(s) in hours or minutes... – 1337475 Sep 2 '12 at 20:09
@AdamJohnston oh I didn't understand your question, hadn't heard the expression video runtime, I see it exists, it gets 225,000 results. But video length gets 6.7 million results. i'll edit my answer – barlop Sep 2 '12 at 22:08

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.