Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Extract all filenames from folder  (Read 2464 times)

0 Members and 1 Guest are viewing this topic.

vandyo

    Topic Starter


    Starter

    Extract all filenames from folder
    « on: February 26, 2009, 01:01:12 PM »
    am trying to use batch to extract all the filenames from a directory & use them to print a menu as selections.  I have listed a snip of code below, but only picks up 9 files as uses env. vars.  Could someone advise me how to change this so as to get all files & have all var. avail to print.  I have searched and tried many ways to use 'shift' but no success.  I know it can be done with a 'for - do', but i'm from the early 80s in computers and I cannot get my head around this.  I guess aging has put too much sticky stuff in my gray matter.  Would appreciate the help as I am getting closer to divorce court every day.

    @Echo off
    cd %CD%\My Tutorial\CH04
    dir /b /a:-d  %1 %2 %3 %4 %5 %6 %7 %8 %9
    pause

    vandyo
    « Last Edit: February 26, 2009, 01:37:49 PM by vandyo »

    GuruGary



      Adviser
      Re: Extract all filenames from folder
      « Reply #1 on: February 26, 2009, 09:04:49 PM »
      I'm not sure I understand exactly what you are trying to accomplish.  To include all command line parameters in a command prompt under Win 2000 / XP, you can use %*, like:
      Code: [Select]
      dir /b /a:-d %*I'm not sure I understand what you are trying to do with "menu selections".  Can you try to explain?

      vandyo

        Topic Starter


        Starter

        Re: Extract all filenames from folder
        « Reply #2 on: February 27, 2009, 06:54:28 AM »
        hi gary, thanks for your help

        I tried your suggestion & it does work just like my example.  I am moving some of my tuts from HD to cd/dvd & intend to add autorun menu to step thru the selections.  The last menu Needs the lesson files (.mov), so that I can extract them from the dir & then print the menu formatting & the part numbers extracted.  On selection the prog would run the selection & return to the menu.  I therefor need the filenames in a variable I can use.  I really don't think 'dir' is the best way to go about it, but as I stated, I have a difficult time understanding the syntax of the for-do command.