The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Help needed. by RetiQlum22006-09-08 12:13:15
  WSH (VBS or JS) by SlyW 2006-09-08 12:58:35
If you are familiar with VBScript or JScript, either can be run within WinXP much like a batch file. Then it is simply a matter of using the FileSystemObject to open/read/write etc the files.

VBScript:
Option Explicit

'::: Delimiter between FileName and First Line
Dim cstrDelimiter
cstrDelimiter = vbTab

Dim strTargetDir
Dim strOutputFileName

Dim objFSO
Dim objInFile
Dim objInFileTS
Dim objOutFile

strTargetDir = "D:\Temp\TextFiles"
strOutputFileName = "D:\FileList.txt"

'::: Create the object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'::: Force overwrite if it exists
Set objOutFile = objFSO.CreateTextFile(strOutputFileName, True)

'::: Loop through the files in the target directory
For Each objInFile In objFSO.GetFolder(strTargetDir).Files
  '::: Open the file for reading
  Set objInFileTS = objInFile.OpenAsTextStream(1)

  '::: Write the record to the output file
  objOutFile.WriteLine objInFile.Name & cstrDelimiter & objInFileTS.ReadLine

  '::: Close the TextStream
  objInFileTS.Close
  Set objInFileTS = Nothing
Next

'::: Close the output file
objOutFile.Close

Set objFSO = Nothing
Set objInFile = Nothing
Set objOutFile = Nothing
[ Reply ]
    Thanks, you're a lifesaver. (n/t) by RetiQlum22006-09-08 13:10:51
      The pleasure is mine. (n/t) by SlyW2006-09-08 13:13:50
    Wow! by CALL-1982006-09-08 14:45:16

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)