Results 1 to 4 of 4
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Batch File to Print File Names to TXT (WinXP)

    Hi,

    I found this Command Line in the Help files. :

    To print a directory listing, type:
    ir > prn
    When you specify prn, the directory list is sent to the printer attached to the LPT1 port. If your printer is attached to a different port, you must replace prn with the name of the correct port.

    You can also redirect output of the dir command to a file by replacing prn with a file name. You can also type a path. For example, to direct dir output to the file Dir.doc in the Records directory, type:
    dir > recordsdir.doc

    If Dir.doc does not exist, dir creates it, unless the Records directory does not exist. In that case, the following message appears: "File creation error "


    I would like to print a list of ALL the files in a certain directory to a text file so I can save it for reference sake. The line "dir > recordsdir.doc" seems to be the one to do the job, but it is not specifying which directory to print the list from. How do I modify the line to print the files from, say the TEST directory on the C: drive?
    Regards,
    Rudi

  2. #2
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Lewiston, Maine, USA
    Posts
    293
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Batch File to Print File Names to TXT (WinXP)

    Hi Rudi,
    You might try something like this:
    DIR C:TEST*.* > C:OUTPUT.TXT

    And if you wanted to appended another directory to the same file:
    DIR C:TEST*.* >> C:OUTPUT.TXT

    HTH
    Bob

  3. #3
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch File to Print File Names to TXT (WinXP)

    The general rule is that either you use the CD command to navigate to the directory on which you want to act, or (as Bob does in his example) SPECIFY the full drive and path name. This can be seen while in a CMD prompt window as well as in writing batch files.

  4. #4
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch File to Print File Names to TXT (WinXP)

    Thanx Bob...that is perfect!
    Thanx BigAl...
    Regards,
    Rudi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •