Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch file commands for files and folders!

31 Jan 2019   #1
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 
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 System SpecsSystem Spec
.
31 Jan 2019   #2
iko22

Windows 7 x64, Vista x64, 8.1 smartphone
 
 

Hello Paul Black,
Quote   Quote: Originally Posted by Paul Black View Post
3. List Folders Only Files.
could you explain this means in a little more detail?
My System SpecsSystem Spec
31 Jan 2019   #3
SIW2

Microsoft Community Contributor Award Recipient

Vista x64 / 7 X64
 
 

What are "Folders only Files" in English?

DIR - list files and folders - Windows CMD - SS64.com
My System SpecsSystem Spec
.

31 Jan 2019   #4
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

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 System SpecsSystem Spec
31 Jan 2019   #5
iko22

Windows 7 x64, Vista x64, 8.1 smartphone
 
 

DIR [folderpathname/*.*] lists everything in the folder called folderpathname. Then use that, plus apply your /A:-D attribute when needed.
My System SpecsSystem Spec
31 Jan 2019   #6
iko22

Windows 7 x64, Vista x64, 8.1 smartphone
 
 

4. DIR *.* /s > 000_Files_List4.txt
My System SpecsSystem Spec
31 Jan 2019   #7
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi iko22,

Quote   Quote: Originally Posted by iko22 View Post
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 System SpecsSystem Spec
31 Jan 2019   #8
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi SIW2,

Quote   Quote: Originally Posted by SIW2 View Post
Thanks, I did have a look at that but without much luck!
My System SpecsSystem Spec
31 Jan 2019   #9
iko22

Windows 7 x64, Vista x64, 8.1 smartphone
 
 

Hi Paul Black,
Quote   Quote: Originally Posted by Paul Black View Post
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 System SpecsSystem Spec
31 Jan 2019   #10
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi iko22,

Quote   Quote: Originally Posted by iko22 View Post
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.
My System SpecsSystem Spec
Reply

 Batch file commands for files and folders!




Thread Tools




Similar help and support threads
Thread Forum
How do I create a batch file to run commands on auto?
the thread that i made previously only got 1 answer that really didnt have anything to do with my problem so thought it would be ok if another one was made, and not trying to spam, here are the commands for the batch file netstop sppvc cd...
General Discussion
Window Batch file to delete folders/subfolders that contain files
I have a root folder called "Names"..It has subfolders ,these subfolders contains files. I will be giving the names of subfolders to be deleted in text file Ex.. John Tom Rambo. I will be reading the folder names from text file & delete only those folders with files inside the folder also ....
General Discussion
Move files from original folder to existing folders - w batch file?
My files have a format of "ID_date_time.d7d Ex: 11111-5_2013_10_07_142149.d7d The ID is 1111-5 and was tested 10/7/2013 at 2:21:49 PM and the file extension is always .d7d The local files are automatically saved here by the program generating the data: C:\Local\Data I want them copied...
General Discussion
[Help] Batch File move every 15.000 files to another folders
Hi guys I'm new here, please help I have about 2 million email files that i want to convert into mbox files. but the tool i used only can convert every 15.000 files. so i need a batch file that can move this 2 million files into another folder (15.000 files each folder) and the folder name...
General Discussion
a simple batch file for copy files and folders
I want to write a batch file that do this for me: - makes a directory with the "yy.mm.dd.hh.mm" as the directory name, - copies files and folders from a TEST directory to above destination, - copies only new (or modified) files from the TEST directory to a separate folder. Any Idea?
General Discussion


Our Sites

Site Links

About Us

Find 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 09:54.
Twitter Facebook Google+