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've prepared a number of video files that will each have their own HTML page. (I'm making a series of lecture videos and trying to keep things simple since I'm a chemist, not a coder.)

I'd like to set up a command at the Windows (v.7) command line that I can copy/paste into the window and have it:

  1. find all MP4 files in the directory
  2. create an HTML file with the same name (without the extension)
  3. 'fill' this HTML file with the template HTML

I'm aware that all these can probably be accomplished in one step, but I don't mind being less elegant – CPU cycles aren't 'expensive' in this case. One example of the filenames is: 11-a - Ion Dipole Interactions.mp4 in case that's helpful.

Here's what I have so far, and how it's breaking. Any ideas on how to make it work?

  1. for %G in (*.mp4) do (copy /Y nul "%nG".html)

    i.e. scan the directory for MP4s, then make 0 byte HTMLs with the same name.

    for %I in (**.*mp4) do (ECHO %~nI) gives me the right filename, but the command listed just keeps giving me the filename %nG.html

  2. for %G in (*.html) do (type SHORT.html>"%G".html)

    SHORT.html is my template-form HTML. I can think of two approaches but can't get either to work:

    1. copy SHORT paste with the final filename for all the MP4s
    2. make the HTMLs, then pipe the text of SHORT into each.

I'm ok with other approaches too, but please be option-explicit in your description!

Obviously, neither has worked so far.

share|improve this question
Hi Kevin! Please post your answer below using the Answer your question button once the system allows you to (should be in about 7hrs). That way you can accept it later and others can vote on it as well. Thanks! By the way, I cleaned up your formatting a little. Click edit to see what changes I made to the code so it's formatted as such. – slhck May 28 '13 at 14:56
Thanks for the fixes! I'll try to come back to this tomorrow and switch to Answer your Question. – Kevin Davies May 28 '13 at 14:59

Answer 1: CGI Script

Your question presumes the creation of HTML pages. Perhaps you really mean that you want custom HTML wrapped around your MP3 filename links?

In case I'm right (apologies if not), a simple cgi script will do the trick. That is, use your favorite language ( Python is mine :-) ) that outputs the template you want to display. This CGI script could take as input the directory you want to browse to / display the contents of, and wrap each entry in the links you want.

For more info, see:

Answer 2: WIKI

Perhaps if you're trying to create a set of slides as part of a interactive learning process, you'll find that a WIKI is a better choice. There are many wiki products out there, find some here:

This way, you can link to custom uploaded videos or videos or mp3's on your own site, but link from one page to the next with simple (non-programming) wiki text like the [linkName | link text here] format.

share|improve this answer
Yes, I am aiming for a 'flipped classroom' approach, but I'm going to embed them into both our LMS and the online homework system later. So, for suggestion 1, I need to have a bit of code for the flash wrapper. An aside - the feedback I got last term pointed out that a few students have gone iPad only - and for some their lack of flash support killed the video for them. I think with my different embed approach this time, html5/flash are both embedded; I have to borrow an iPad sometime this summer to verify. Thanks for the feedback! Sadly, Excel is my preferred prog. language these days... – Kevin Davies May 28 '13 at 15:40

Doh. Time to hang my head in shame, and post that I finally fixed it.

For the good of all, here's the final command:

for %I in (*.mp4) do (copy /Y SHORT.htm "%~nI.html")

For one thing, I forgot that SHORT was named HTM to keep it unique in my commands. The rest was realizing I didn't have to copy nul. Which shows that I should have had more coffee first. :*/

share|improve this answer

You must log in to answer this question.

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