Re: Looking for a dos command

Subject: Re: Looking for a dos command
From: Geoff Lane <geoff -at- gjctech -dot- co -dot- uk>
To: TECHWR-L <techwr-l -at- lists -dot- techwr-l -dot- com>
Date: Tue, 15 Aug 2006 20:50:43 +0100

On Tuesday, August 15, 2006, Gene Kim-Eng wrote;

> DIR /S /B /A-D

> This will list all files found in a directory and all its
> subdirectories in one list and exclude the directory
> names.
---

Unfortunately, that omits the file sizes.

Here's a little vbScript-ette that should do what John needs. Just
change the ROOTFOLDER AND LISTFILE constants as appropriate, save the
file as (say) listfiles.vbs, and run with:

wscript listfiles.vbs

Change the INCLUDEPATH constant to False if you don't want to include
the full path to each file.

------------8<------------------
Const ROOTFOLDER = "G:\MyFiles"
Const LISTFILE = "G:\MyFiles\filelist.txt"
Const INCLUDEPATH = True


Sub ParseFolder(objFolder, iLevel)
Dim objFile, strPath, strLine
strPath = objFolder.Path
bFound = False
For Each objFile In objFolder.Files
If INCLUDEPATH Then
strLine = strPath & "\"
Else
strLine = ""
End If
strLine = strLine & objFile.Name & Chr(9) & objFile.Size
fTarget.WriteLine strLine
Next

Dim objSubFolder
If Not bFound Then
For Each objSubFolder In objFolder.SubFolders
ParseFolder objSubFolder, iLevel + 1
Next
End If

End Sub

'-----------------[ MAIN ]---------------------
Dim fso, objSubFolders, objFolder, fTarget
Set fso = CreateObject("Scripting.FileSystemObject")
Set fTarget = fso.OpenTextFile(LISTFILE, 2, True)
Set objFolder = fso.GetFolder(ROOTFOLDER)
ParseFolder objFolder, 0
fTarget.Close
Set fTarget = Nothing
Set objFolder = Nothing
Set fso = Nothing

--------------8<-------------------------

The output should be a tab-delimited file suitable for import into
Excel etc.

HTH,

--
Geoff

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

WebWorks ePublisher Pro for Word features support for every major Help
format plus PDF, HTML and more. Flexible, precise, and efficient content
delivery. Try it today! http://www.webworks.com/techwr-l

Easily create HTML or Microsoft Word content and convert to any popular Help file format or printed documentation. Learn more at http://www.DocToHelp.com/TechwrlList

---
You are currently subscribed to TECHWR-L as archive -at- infoinfocus -dot- com -dot-

To unsubscribe send a blank email to
techwr-l-unsubscribe -at- lists -dot- techwr-l -dot- com
or visit http://lists.techwr-l.com/mailman/options/techwr-l/archive%40infoinfocus.com


To subscribe, send a blank email to techwr-l-join -at- lists -dot- techwr-l -dot- com

Send administrative questions to lisa -at- techwr-l -dot- com -dot- Visit
http://www.techwr-l.com/techwhirl/ for more resources and info.


Follow-Ups:

References:
Looking for a dos command: From: John Posada
Re: Looking for a dos command: From: Gene Kim-Eng

Previous by Author: Re: Looking for a dos command
Next by Author: Re: Looking for a dos command
Previous by Thread: Re: Looking for a dos command
Next by Thread: Re: Looking for a dos command


What this post helpful? Share it with friends and colleagues:


Sponsored Ads