need help creating a file/folder listing *.bat file


  1. Posts : 88
    Win10
       #1

    need help creating a file/folder listing *.bat file


    pretty much as the subject states, l had one in the past but l cant remember where l put it and forget how it was written.

    basically l just want a script that lists files and folders in a specific directory without listing the sub folders within that dir (just a bog standard list of files and folders without any other information).

    a bonus would be if l were able to have it on my send to menu and it saved the text file to that folder. basically put l just want to output a list files and folders in specific directory.

    any help would be gratefully appreciated.
      My Computers


  2. Posts : 4,188
    Windows 11 Pro, 22H2
       #2

    Hope I understand the question properly. If you simply want a raw listing of all *.bat files in a folder, just run this command:

    Code:
    "dir *.bat /b"
    The "/b" gives a bare listing with nothing but the file names. You can redirect that output to a file like this:

    Code:
    dir *.bat /b > D:\OutputFile.txt
    If you want a directory listing a specific folder, do it like this:

    Code:
    dir D:\MyFolder\*.bat /b > D:\OutputFile.txt
    Finally, add a "/s" if you want to recurse subdirectories.

    Naturally, you can put that into a batch file if you wish.

    Did I understand the question correctly? If you need anything more, feel free to let me know.
      My Computers


  3. Posts : 88
    Win10
    Thread Starter
       #3

    yes thats the sort of thing l want to do, but when testing l get blank files with nothing in.

    the closest lve gotten to actual content within the file is this code

    Code:
    @echo off
    dir %1 /b /o:gn > "%temp%\Listing"
    start /w notepad "%temp%\Listing"
    del "%temp%\Listing"
    exit
    however annoyingly it only seems to be listing the windows dir rather than the dir lm in.

    - - - Updated - - -

    just an update:

    lve been hanging on this page for the last 10m 5 Ways to Print Folder and Directory Contents in Windows

    lve managed to get the no.2 option working generally how l want it to seems once l inserted the reg part of it the script listed something else other than the windows dir.
      My Computers


  4. Posts : 4,188
    Windows 11 Pro, 22H2
       #4

    Try this:

    Code:
    @echo off
    cd /d %~dp0
    dir . /b /o:gn > "%temp%\Listing"
    start /w notepad "%temp%\Listing"
    del "%temp%\Listing"
    exit
    The "cd /d %~dp0" changes directories to the current directory.
    Then, I replaced the "%1" with a ".". The "." acts upon the current directory, giving you a directory listing of the current directory. The %1 would imply to use whatever argument you passed to the batch file. If that was your intention, sorry for the error.
      My Computers


  5. Posts : 88
    Win10
    Thread Starter
       #5

    not a problem, also eventually ended up there though you replied just before l came across the information.

    only thing lm left with sorting now is a way to edit the file on a phone without messing up the formatting, every app lve used in the past seems to add line spacing when l press enter on my phone for a new line or when it saves the file on my phone removes the next line completely ending up in one large paragraph :/ the idea of my whole folder listing was so l could keep track on projects the editor part mainly so l can add notes for progression so when l got back to my PC/laptop l could manage the files and update as required without running around with a notepad with a large list on it lol.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 04:47.
Find Us




Windows 10 Forums