Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to names of file in a directory 1

Status
Not open for further replies.

IS300

MIS
Oct 29, 2003
121
0
0
CA
I would like a script that would get the file names of all files in a particular directory. I would then like the results put into a text file that I can review.

Is this possibe?

Thanks in advance.
 
try something like this...
Code:
strFolder = "C:\Temp"
strTextFile = "C:\myTextFile.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
Set objTextFile = objFSO.CreateTextFile(strTextFile, ForAppending, True)

For Each File in objFolder.Files
  objTextFile.WriteLine File.Name
Next

Set objTextFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing

Tony
________________________________________________________________________________
 
Hello IS300,

That's often repeated and members are tested for over-dose of repeating! How about something like this.
Code:
filespec="d:\test\xyz.txt"
folderspec="d:\bin"

set fso=creaeobject("scripting.filesystemobject")
if not fso.folderexists(folderspec) then
    wscript.echo "Folder " & folderspec & " does not exist. Operation aborted."
    set fso=nothing
    wscript.quit 9
end if
sinfo=""
for ofile in fso.getfolder(folderspec).files
    sinfo=sinfo & ofile.path & vbcrlf 
next
set ots=fso.opentextfile(filespec,2,true)
ots.write sinfo
ots.close
set ots=nothing
set fso=nothing
Please do not followup with more properties or subdirectory walk. That you can just browser this forum without even using search utility. After initiated with this skeleton, read the documentation to fill out functionalities needed.

regards - tsuji
 
Hello FestSXS,

Sorry for duplicating. Writing up at the time interim. Please ignore my off-topic notes.

regards - tsuji
 
Awesome FesterSXS,

That is exactly what I wanted.

Thanks!
 
I am looking for almost the same thing with a twist.

I need the directory contents of a particual directory. I have a mapped drive which contains all users who log into my network. Under that folder is a cookies folder. I need all the files in the cookies folder then move to next user.

J:\
--User1
----cookies
------files.........
--user2
----cookies
------files.........
and so on. I do not want the other folder and files under that user that's why I am trying to be explicit in what I want returned.

Can anyone help?
 
there have been a number of posts recently about this, recursive folder searching and PHV posted a way to only have it go down one level. have a look over the posts for the last week or so and you will find exactly what you are after
 
the subject of the post was "Limit subfolder recursion?" have a look on page 2 or 3 of the recent posts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top