Batch file directory of files in folder


by dingpud
Tags: batch, directory, file, files, folder
dingpud
dingpud is offline
#1
Jul27-11, 02:25 PM
P: 201
Hello all. I am far from a programmer, but have found a lot of use out of a batch file that I found. The file is as follows:
dir /s*.*>dirlist.txt
This file, typed into a notepad file, then saved as a .bat file has worked perfectly on my XP system. I tried to use in in W7, and it just prints to a blank notepad file. Is something different with W7?

I did, through a Google search, find that when renaming the file from .txt to .bat, I had to use uppercase for the .BAT, but that was an easy fix.....

Any suggestions?
Thanks,
Phys.Org News Partner Science news on Phys.org
NASA's space station Robonaut finally getting legs
Free the seed: OSSI nurtures growing plants without patent barriers
Going nuts? Turkey looks to pistachios to heat new eco-city
chiro
chiro is offline
#2
Jul27-11, 08:38 PM
P: 4,570
Quote Quote by dingpud View Post
Hello all. I am far from a programmer, but have found a lot of use out of a batch file that I found. The file is as follows:
dir /s*.*>dirlist.txt
This file, typed into a notepad file, then saved as a .bat file has worked perfectly on my XP system. I tried to use in in W7, and it just prints to a blank notepad file. Is something different with W7?

I did, through a Google search, find that when renaming the file from .txt to .bat, I had to use uppercase for the .BAT, but that was an easy fix.....

Any suggestions?
Thanks,
I tried the same thing on my C drive and I got an access denied message. I tried the same thing on a different drive and it worked.

I'm guessing you need to change your permissions for the C drive to allow you to do this on that drive. An easy way to check if you can do this is to open the command prompt and type "dir /s *.* > dirstruc.txt" and if you get the denied message, you'll know that you need to change the permissions.
dingpud
dingpud is offline
#3
Aug1-11, 10:00 AM
P: 201
I will try that when I get a chance... Currently when I run the one that I posted, it just gives me a blank notepad file. It use to create the same file listing.txt which had the directory in the notepad file. I do not get any errors when I run it.

DrGreg
DrGreg is offline
#4
Aug1-11, 01:36 PM
Sci Advisor
PF Gold
DrGreg's Avatar
P: 1,806

Batch file directory of files in folder


Are you sure that the txt file is even being created in the first place? If the current directory is set to "C:\", then your command will try to create the txt file within "C:\". I use Vista and on my machine non-administrators don't have permission to create files there. The solution is to specify a place where you are allowed to write, e.g.

dir /s *.* > C:\Users\InsertYourLoginNameHere\dirlist.txt
or, better still

dir /s *.* > %HOMEDRIVE%%HOMEPATH%\dirlist.txt
which has the same effect.
dingpud
dingpud is offline
#5
Aug1-11, 04:57 PM
P: 201
Well, I found the original batch file... went in to edit it, and it seems as though the only difference were the spaces around the *.* This file works exactly like it use to.
dir /s *.* >dirlist.txt
Saved as a batch file will allow me to copy and paste the batch file in a folder, double click on it, then read the .txt file that it creates with a list of all the files, folders, and sub-folders within the folder. I can then export to Excel and get a nice neat list of all the files.
Thanks all. The info about including the directory to write to will help reduce the amount of renaming and copying and pasting that I'll have to do....

EDIT: This works on both XP and W7


Register to reply

Related Discussions
A new computer virus attacks a folder consisting of 200 files Set Theory, Logic, Probability, Statistics 3
using a batch file to create NAMELIST input file for FORTRAN Programming & Computer Science 0
My network directory file synch batch file thing :) Computing & Technology 2
more batch files Computing & Technology 0
Creating Batch Files Computing & Technology 10