Batch file directory of files in folder

  • Thread starter Thread starter dingpud
  • Start date Start date
  • Tags Tags
    Batch File files
Click For Summary

Discussion Overview

The discussion revolves around the use of a batch file to create a directory listing of files within a folder. Participants explore issues encountered when transitioning from Windows XP to Windows 7, particularly regarding file permissions and command syntax.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • One participant describes a batch file command that worked on Windows XP but resulted in a blank file on Windows 7, prompting questions about potential differences in the operating systems.
  • Another participant suggests that permission issues on the C drive may be causing access denied messages, recommending a command prompt test to check permissions.
  • A participant raises the possibility that the output file may not be created if the current directory is set to a location where the user lacks write permissions, proposing alternative paths for output.
  • One participant discovers that the only difference in their original batch file was the spacing around the wildcard, which resolved the issue and allowed the command to function correctly on both operating systems.

Areas of Agreement / Disagreement

Participants express various experiences and suggestions regarding the batch file's functionality across different Windows versions. There is no consensus on a single solution, as multiple factors such as permissions and command syntax are discussed.

Contextual Notes

Participants mention potential limitations related to user permissions on different drives and the importance of specifying output paths to avoid issues with file creation.

dingpud
Messages
198
Reaction score
1
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,
 
Technology news on Phys.org
dingpud said:
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.
 
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.
 
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.

Code:
dir /s *.* > C:\Users\InsertYourLoginNameHere\dirlist.txt

or, better still

Code:
dir /s *.* > %HOMEDRIVE%%HOMEPATH%\dirlist.txt

which has the same effect.
 
Well, I found the original batch file... went into 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
 

Similar threads

  • · Replies 20 ·
Replies
20
Views
5K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 2 ·
Replies
2
Views
28K
Replies
1
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K