Jump to content

.vbs script help


Recommended Posts

Hello,

I need some help with a .vbs script please (very basic script, not visual basic).

I need to find a way that a script can read through a text file, line by line, and submit it to a function as a variable.... Some thing along the line of: For 'every line individualy' Do 'this'.

My second problem is that i need to be able to copy a folder, including its subdirectorys to another place. How could i go about this.

Thanks for any help you can give! Im a bit of a novice as you can tell!

Thanks!

Edited by the_oliver
Link to comment
Share on other sites


Hope these help!

example 1

strInFile = "C:\Temp\temp.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strInFile, 1)
Do Until objFile.AtEndOfStream
strChrs = objFile.ReadLine
wscript.echo strChrs
Loop

example 2

strSPath = "C:\SomePath\SourceDir"
strDPath = "C:\SomePath\DestDir"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Sub CopyTree(srcPath, dstPath)
Dim objSubFolders, objSubFolder
On Error Resume Next
Set objSubFolders = objFSO.GetFolder(srcPath).SubFolders
For Each objSubFolder in objSubFolders
objFSO.CreateFolder dstPath & "\" & objSubFolder.Name
CopyTree srcPath & "\" & objSubFolder.Name, dstPath & "\" & objSubFolder.Name
Next
End Sub
CopyTree strSPath, strDPath

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...