Jump to content

Read From File Help


Recommended Posts

OK.Here is a small piece of code.If you need more code just ask,i thought this might be enough.

What I am wanting to do is for each line read is to rewrite it later in script.

What it's doing is reading file and folder paths from .txt file and i want to insert those paths into places later down the script.Because this script will output a .vbs .

So how do i get each read line which is "$folder" and place it at "$folder" position in the .vbs output.

Thank in advance for any help

While 1
        $folder = FileReadLine($poo)
        If @error = -1 Then ExitLoop
           WEnd
_VBS()

Func _VBS()
    Local $vbs

$vbs = "Option Explicit"& @CRLF _
 &"Dir.AddTree "&'"'&$folder&'"'&", true"& @CRLF _  

   FileWrite(@TempDir & "\burn.vbs", $vbs)
   RunWait(@ComSpec & " /c " & 'cscript.exe //E:VBScript '&@TempDir & "\burn.vbs",@SystemDir)
   FileDelete(@TempDir & "\burn.vbs")
EndFunc
Link to comment
Share on other sites

Maybe I didn't get point :-)

Global $vbs

While 1
 $folder = FileReadLine($poo)
 If @error = -1 Then ExitLoop
 $vbs &= "Option Explicit" & @CRLF _
         & "Dir.AddTree " & '"' & $folder & '"' & ", true" & @CRLF ; ?
WEnd
_VBS()

Func _VBS()
 FileWrite(@TempDir & "\burn.vbs", $vbs)
 RunWait(@ComSpec & " /c " & 'cscript.exe //E:VBScript ' & @TempDir & "\burn.vbs", @SystemDir)
 FileDelete(@TempDir & "\burn.vbs")
EndFunc   ;==>_VBS
Edited by Zedna
Link to comment
Share on other sites

@Zedna

Thanks for the quick reply.i should try again.The .vbs script is mush longer than what i put and i actually put a line in the example that shouldn't have been.Take a look at this and see if you can help me.And if i run what is below i get lots of errors.And i know its not what you put ,but i just realized i had put wrong line in first post. :D:D

Thanks Again

Global $vbs

While 1
 $folder = FileReadLine($poo)
 If @error = -1 Then ExitLoop
 $vbs = "Dir.AddTree " & '"' & $folder & '"' & ", true" & @CRLF  ;<this is the line i will be adding to the .vbs and will be adding it many times according to .txt file

WEnd
_VBS()

Func _VBS()
 FileWrite(@TempDir & "\burn.vbs", $vbs)
 RunWait(@ComSpec & " /c " & 'cscript.exe //E:VBScript ' & @TempDir & "\burn.vbs", @SystemDir)
 FileDelete(@TempDir & "\burn.vbs")
EndFunc   ;==>_VBS

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
 Share

  • Recently Browsing   0 members

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