I need a program that generates a text file on all the file names and meta data

Joined
11 Mar 2004
Messages
3,454
I need a program that generates a text file on all the file names and meta data of the text file in a folder. In essence i just want to take everything in folder detail view and put it into a text file. any ideas anyone?

-Sean
 
open up a command prompt go to the root folder containing the info you need in a text folder and type this into the cmd line

dir /b/p > text.txt (change the text name to whatever you want, hope this is what you mean.
 
that only shows the folders and files within the root folder that you are in, but does not expose the files within the file tree, perhaps there is a program for that.
 
the files within the file tree


Just include a "/s" with the /b, and ignore the /p as that would pause if the screen were to fill, and wait for a key to be pressed, however, the message would not be displayed on the screen
 
Ok that worked ok but is there any way i can get the date modified in the txt file as well. thats a important part.
 
how do you mean date modified?
 
Go to a folder. click on view and detail

Over to the right side it will say what date the file was last modified on. I assume thats meta data for the file.
 
well if you did this:

dir /a:d > text.txt it'll give you that info.
 
umm.. dir /a:d will only display the directories.. not the files

"dir /tw /s > list.txt" will list the "time last written" field as well as all the files in sub directories

edit: doing a dir /a /tw /s will include hidden/system files in that list...

edit: if you want something a lot more fancier.. you would probably have to look into some WSH scripting (hint: google VBScript and File System Object if you want to go down that road.)
 
for those that care.. the help file on the dir command is fairly helpful

dir /?

Code:
Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
  [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

  [drive:][path][filename]
              Specifies drive, directory, and/or files to list.

  /A          Displays files with specified attributes.
  attributes   D  Directories                R  Read-only files
               H  Hidden files               A  Files ready for archiving
               S  System files               -  Prefix meaning not
  /B          Uses bare format (no heading information or summary).
  /C          Display the thousand separator in file sizes.  This is the
              default.  Use /-C to disable display of separator.
  /D          Same as wide but files are list sorted by column.
  /L          Uses lowercase.
  /N          New long list format where filenames are on the far right.
  /O          List by files in sorted order.
  sortorder    N  By name (alphabetic)       S  By size (smallest first)
               E  By extension (alphabetic)  D  By date/time (oldest first)
               G  Group directories first    -  Prefix to reverse order
  /P          Pauses after each screenful of information.
  /Q          Display the owner of the file.
  /S          Displays files in specified directory and all subdirectories.
  /T          Controls which time field displayed or used for sorting
  timefield   C  Creation
              A  Last Access
              W  Last Written
  /W          Uses wide list format.
  /X          This displays the short names generated for non-8dot3 file
              names.  The format is that of /N with the short name inserted
              before the long name. If no short name is present, blanks are
              displayed in its place.
  /4          Displays four-digit years

Switches may be preset in the DIRCMD environment variable.  Override
preset switches by prefixing any switch with - (hyphen)--for example, /-W.
 
thanks fitz. i got it going then i am able to use import in excel to tweak the data. repps too who i can give them too.
 
'---------------------------------------------------------
'Written by Vic Laurie, January, 2006
'All rights reserved. Provided as is
'with no guarantees, express or implied
'User assumes all responsibility
'---------------------------------------------------------
'Description- Lists all files in a selected folder and its subfolders
'that are of a given type selected by user.
'Uses Dir with switches
Option Explicit
Dim sFldrInput1, sFldrInput2, sExtension, introMsg, sSwitches
introMsg = msgBox ("This program creates a list of all files of a given type"& vbCrLf & "that are in a selected folder and optionally its subfolders." & vbCrLf & "If there are many files, it may take a few minutes."& vbCrLf & "A message will appear when the list is finished.",vbOKCancel)
If introMsg = vbCancel Then
Wscript.Quit
End If
ChooseFolder sFldrInput1,"Select the folder containing files to be listed"
ChooseFolder sFldrInput2, "Select the folder where list is to be put"
ChooseExtension sExtension
ChooseSubfldr sSwitches
MakeList sFldrInput1, sFldrInput2, sExtension
Wscript.Quit
sub ChooseFolder(sFldrChoice, sSelectionString)
dim objShell, objFolder, objFolderItem, strPath, msgValue
Const DESK_TOP = &H10&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
sFldrChoice = ""
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(DESK_TOP)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, sSelectionString, OPTIONS, strPath)

If objFolder Is Nothing Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
sFldrChoice = objFolderItem.Path
msgValue = msgBox("You selected "& sFldrChoice, vbOKCancel)
If msgValue = vbCancel Then
Wscript.Quit
End If
If Len(sFldrChoice) = 3 then
chkForDrv sFldrChoice
End if
End sub
Sub ChooseExtension(sExtension)
sExtension = InputBox("Enter extension of files to be listed.", "Name of extension")
If sExtension = "" Then
Wscript.Quit
End If
chkForDot sExtension
End sub
Sub MakeList(sourceFldr, listFldr, Extension)
Const sdirCmd ="cmd /c dir "
Const sWildCard = "\*."
Const sRedirect =">"
dim listFile
dim sStatement
dim objWshell
Dim oIE, oIEDoc, sMsg
listFile ="\list" & Extension & ".txt"
sStatement = sdirCmd & chr(34) & sourceFldr & sWildcard & Extension & chr(34) & sSwitches & sRedirect & chr(34) & listFldr & listFile & chr(34)
'The next part is just to display a message while making list
set objWshell=Wscript.CreateObject("Wscript.Shell")
Set oIE = Wscript.CreateObject("InternetExplorer.Application")
oIE.Navigate "about:blank"
do while oIE.busy : wscript.sleep 10 : loop
Set oIEDoc = oIE.Document
oIE.AddressBar = False
oIE.StatusBar = False
oIE.ToolBar = False
oIE.height=200
oIE.width=300
oIE.Resizable = False
oIE.Visible = True
sMsg= "<p><center>List is being made.<br>Please wait.<br>Large numbers of files may take several minutes.</center></p>"
oIEDoc.Body.Innerhtml= sMsg
'List the files
objWshell.Run sStatement,7,true
Set oIEDoc = Nothing
oIE.Quit
Set oIE = Nothing
set objWshell = Nothing
msgBox "List has been made of " & sExtension & " files"
End sub
Sub chkForDrv(sFldrChoice)
Dim oRe, bMatch
set oRe = New RegExp
oRe.pattern = "[a-zA-Z]:\\$"
bMatch= oRe.Test(sFldrChoice)
If bMatch Then sFldrChoice= Left(sFldrChoice, 2)
Set oRe = Nothing
End sub
Sub chkForDot(sExtension)
Dim lenExt, truncStr
lenExt = Len(sExtension)
truncStr =left(sExtension,1)
If truncStr = "." then
sExtension = right(sExtension,lenExt-1)
End if
End sub
Sub ChooseSubfldr(sSwitches)
dim sSubfldrYesNo
sSubfldrYesNo = msgBox("Do you want to list files in all subfolders also?", vbYesNoCancel+vbQuestion)
Select Case sSubfldrYesNo
case vbCancel
Wscript.Quit
case vbNo
sSwitches = " /o:g"
case vbYes
sSwitches = " /o:g /s"
End select
end sub







.............

Dont not take below the .......... copy and save as .vbs
 
That is cool. I may have to modify that some to what i need. I can write in vbs a bit. Lol ironically this is the first batch files i have ever made to do this other stuff though. I decided its good to be well rounded as a lot of patches we push is through cmd.
 
hmm.. he's doing shell commands in that script. I would prefer to use the File System Object.. you can grab other file info through the file system object that you couldn't get through a dir command (things like file version, etc..). His command also does not list hidden or system folders and/or files (easily fixed by adding the correct switches to his command constant)

Using the FSO would usually require setting up an array of the list of files in a folder and looping through the array to grab the requested info and writing out to a file.. subdirectory recusion with the FSO is a little more difficult, You would probably look at seeting up a recusrive call to a function that performs the lookups.

Would probably take a couple hours work (maybe longer if you aren't all that familiar with scripting/programming) to whip up a vbs script and test it.
 
Here is one for hidden files if you need it.

................

'---------------------------------------------------------
'Written by Vic Laurie, January, 2006
'All rights reserved. Provided as is
'with no guarantees, express or implied
'User assumes all responsibility
'---------------------------------------------------------
'Description- Lists all files in a selected folder
'and (optionally its subfolders
'Uses Dir with various switches
Option Explicit
Dim sFldrInput1, sFldrInput2,introMsg, sSwitches
introMsg = msgBox ("This program creates a list of all hidden files that are in" & vbCrLf & "a selected folder and its subfolders (if desired)." & vbCrLf & "If there are many files, it may take a few minutes."& vbCrLf & "A message will appear when the list is finished.",vbOKCancel)
If introMsg = vbCancel Then
Wscript.Quit
End If
ChooseFolder sFldrInput1,"Select the folder containing files to be listed"
ChooseFolder sFldrInput2, "Select the folder where list is to be put"
ChooseSubfldr sSwitches
MakeList sFldrInput1, sFldrInput2, sSwitches
Wscript.Quit
sub ChooseFolder(sFldrChoice, sSelectionString)
dim objShell, objFolder, objFolderItem, strPath, msgValue
Const DESK_TOP = &H10&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
sFldrChoice = ""
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(DESK_TOP)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, sSelectionString, OPTIONS, strPath)

If objFolder Is Nothing Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
sFldrChoice = objFolderItem.Path
msgValue = msgBox("You selected "& sFldrChoice, vbOKCancel)
If msgValue = vbCancel Then
Wscript.Quit
End If
If Len(sFldrChoice) = 3 then
chkForDrv sFldrChoice
End if
End sub
Sub ChooseSubfldr(sSwitches)
dim sSubfldrYesNo
sSubfldrYesNo = msgBox("Do you want to list files in all subfolders also?", vbYesNoCancel)
Select Case sSubfldrYesNo
case vbCancel
Wscript.Quit
case vbNo
sSwitches = " /A:H"
case vbYes
sSwitches = " /A:H /s"
End select
End sub
Sub MakeList(sourceFldr, listFldr, sSwitches)
Const sdirCmd ="cmd /c dir "
Const sWildCard = "\*.*"
Const sRedirect =">"
dim listFile
dim sStatement
dim objWshell
Dim oIE, oIEDoc, sMsg
listFile ="\list_of_hidden_files.txt"
sStatement = sdirCmd & chr(34) & sourceFldr & sWildcard & chr(34) & sSWitches & sRedirect & chr(34) & listFldr & listFile & chr(34)
'The next part is just to display a message while making list
set objWshell=Wscript.CreateObject("Wscript.Shell")
Set oIE = Wscript.CreateObject("InternetExplorer.Application")
oIE.Navigate "about:blank"
do while oIE.busy : wscript.sleep 10 : loop
Set oIEDoc = oIE.Document
oIE.AddressBar = False
oIE.StatusBar = False
oIE.ToolBar = False
oIE.height=200
oIE.width=300
oIE.Resizable = False
oIE.Visible = True
sMsg= "<p><center>List is being made.<br>Please wait.<br>Large numbers of files may take several minutes.</center></p>"
oIEDoc.Body.Innerhtml= sMsg
'List the files
objWshell.Run sStatement,7,true
Set oIEDoc = Nothing
oIE.Quit
Set oIE = Nothing
set objWshell = Nothing
msgBox "List has been made of hidden files"
End sub
Sub chkForDrv(sFldrChoice)
Dim oRe, bMatch
set oRe = New RegExp
oRe.pattern = "[a-zA-Z]:\\$"
bMatch= oRe.Test(sFldrChoice)
If bMatch Then sFldrChoice= Left(sFldrChoice, 2)
Set oRe = Nothing
End sub


..............
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back