Batch file commands for files and folders!

Page 1 of 2 12 LastLast

  1. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
       #1

    Batch file commands for files and folders!


    I am putting together a batch file that I can copy into the root of a USB or external HDD.

    Within the batch file I have setup a menu with four options. When you press one of these options it generates a .txt file with the relevant information. I have completed the first two of the four options but I am having difficulty with the last two!

    I don't really want to include the drive letter if possible.

    Options:

    1. List Files Only.
    2. List Folders Only.
    3. List Folders Only Files.
    4. List Files, Folders And Folders Files.

    Code:

    1. dir /b /a-d > 000_Files_List1.txt <= This works as required.
    2. dir /b /a:d > 000_Files_List2.txt <= This works as required.
    3. ??? > 000_Files_List3.txt
    4. ??? > 000_Files_List4.txt

    Thanks.
      My Computer


  2. Posts : 2,798
    Windows 7 x64, Vista x64, 8.1 smartphone
       #2

    Hello Paul Black,
    Paul Black said:
    3. List Folders Only Files.
    could you explain this means in a little more detail?
      My Computer


  3. Posts : 16,149
    7 X64
       #3

    What are "Folders only Files" in English?

    DIR - list files and folders - Windows CMD - SS64.com
      My Computers


  4. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #4

    The List Folders Only Files are basically, within the root of the USB there is for example a folder named ABC. I would like to do is just list the files within that ABC folder. The same as using the /b /a-d command for getting just the files in the root of the USB, but just for the files in that ABC folder.

    Thanks.
      My Computer


  5. Posts : 2,798
    Windows 7 x64, Vista x64, 8.1 smartphone
       #5

    DIR [folderpathname/*.*] lists everything in the folder called folderpathname. Then use that, plus apply your /A:-D attribute when needed.
      My Computer


  6. Posts : 2,798
    Windows 7 x64, Vista x64, 8.1 smartphone
       #6

    4. DIR *.* /s > 000_Files_List4.txt
      My Computer


  7. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #7

    Hi iko22,

    iko22 said:
    4. DIR *.* /s > 000_Files_List4.txt
    That gives all the dates, times, sizes, direciories etc. I am only after the file names, exactly as the command dir /b /a-d produces for the file names on the root, but this time just for the sub-folders, excluding the root files, preferably without the drive letter as well!
      My Computer


  8. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #8

    Hi SIW2,

    Thanks, I did have a look at that but without much luck!
      My Computer


  9. Posts : 2,798
    Windows 7 x64, Vista x64, 8.1 smartphone
       #9

    Hi Paul Black,
    Paul Black said:
    Hi iko22,



    That gives all the dates, times, sizes, direciories etc. I am only after the file names, exactly as the command dir /b /a-d produces for the file names on the root, but this time just for the sub-folders, excluding the root files, preferably without the drive letter as well!
    DIR *.* /s /b /a-d > 000_Files_List4.txt
      My Computer


  10. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #10

    Hi iko22,

    iko22 said:
    DIR *.* /s /b /a-d > 000_Files_List4.txt
    That works for 4. List Files, Folders And Folders Files, I can live with that even though it shows the drive letter. I don't think I will get around that unless I write some code etc!

    I came up with dir /b /s /a:-d, which produces exactly the same results.

    Now I just need to get it to list the files in the sub-folders only.

    Thanks.
    Last edited by Paul Black; 31 Jan 2019 at 15:30.
      My Computer


 
Page 1 of 2 12 LastLast

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

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