|
|
gh0std0g74
Thanked: 37 Posts: 590
|
 |
« Reply #16 on: October 18, 2009, 05:06:05 AM » |
|
Cscript is invoked ***once*** for each line of each text file.
yes...that's my point.. thanks for clarifying my bad english. If each text file has 3000 lines and there are 10 such files for example, then cscript is invoked 3000*10 times.... am i correct to say that?
|
|
|
|
gh0std0g74
Thanked: 37 Posts: 590
|
 |
« Reply #17 on: October 18, 2009, 05:10:51 AM » |
|
I wonder, gh0std0g74, if you have tested your vbs solution?
and i wonder why you think i didn't C:\test>more test.vbs Set objFS=CreateObject("Scripting.FileSystemObject") strFolder = "c:\test" Set objFolder = objFS.GetFolder(strFolder) Go (objFolder) Sub Go(objDIR) If objDIR <> "\System Volume Information" Then For Each eFolder in objDIR.SubFolders Go eFolder Next End If For Each strFile In objDIR.Files name =strFile.Name If objFS.GetExtensionName(strFile) = "txt" Then Set objFile = objFS.OpenTextFile(name) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine WScript.Echo Mid(strLine,1,10) Loop Set objFile = Nothing End If Next End Sub C:\test>more file.txt file.txt line one file.txt line two
C:\test>more file1.txt file1.txt line one file1.txt line two
C:\test>more file2.txt file2.txt line one file2.txt line two
C:\test>cscript /nologo test.vbs file.txt l file.txt l file1.txt file1.txt file2.txt file2.txt
so what's your nitpick all about?
|
|
|
|
|
|
Star-Fire Topic Starter
Posts: 13

|
 |
« Reply #19 on: October 22, 2009, 09:39:37 AM » |
|
Set objFS=CreateObject("Scripting.FileSystemObject") strFolder = "c:\test" Set objFolder = objFS.GetFolder(strFolder) Go (objFolder) Sub Go(objDIR) If objDIR <> "\System Volume Information" Then For Each eFolder in objDIR.SubFolders Go eFolder Next End If For Each strFile In objDIR.Files name =strFile.Name If objFS.GetExtensionName(strFile) = "txt" Then Set objFile = objFS.OpenTextFile(name) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine WScript.Echo Mid(strLine,1,10) Loop Set objFile = Nothing End If Next End Sub How i can save all line to one file? 
|
I'm bad English
|
|
|
Salmon Trout
Thanked: 501 Posts: 7,365
Computer: Specs Experience: Guru OS: Linux variant
|
 |
« Reply #20 on: October 22, 2009, 11:59:04 AM » |
|
How i can save all line to one file? 
cscript //nologo scriptname.vbs > file.txt
|
|
|
|
Star-Fire Topic Starter
Posts: 13

|
 |
« Reply #21 on: October 27, 2009, 02:37:42 AM » |
|
Sorry, I want say, how i can create output when run this code: Set objFS=CreateObject("Scripting.FileSystemObject") strFolder = "c:\test" Set objFolder = objFS.GetFolder(strFolder) Go (objFolder) Sub Go(objDIR) If objDIR <> "\System Volume Information" Then For Each eFolder in objDIR.SubFolders Go eFolder Next End If For Each strFile In objDIR.Files name =strFile.Name If objFS.GetExtensionName(strFile) = "txt" Then Set objFile = objFS.OpenTextFile(name) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine WScript.Echo Mid(strLine,1,10) Loop Set objFile = Nothing End If Next End Sub I don't know vbs >_<
|
I'm bad English
|
|
|
|
|
Star-Fire Topic Starter
Posts: 13

|
 |
« Reply #23 on: November 01, 2009, 11:26:37 PM » |
|
I have save all your code in file vbs and run it. Program run and print each line on each window and don't create output file. Set objFS=CreateObject("Scripting.FileSystemObject") strFolder = "G:\AH\aa" Set objFolder = objFS.GetFolder(strFolder) Go (objFolder) Sub Go(objDIR) If objDIR <> "\System Volume Information" Then For Each eFolder in objDIR.SubFolders Go eFolder Next End If For Each strFile In objDIR.Files name =strFile.Name If objFS.GetExtensionName(strFile) = "txt" Then Set objFile = objFS.OpenTextFile(name) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine WScript.Echo Mid(strLine,1,10) Loop Set objFile = Nothing End If Next End Sub "G:\AH\aa" it my path and folder "aa" have many file txt. My "Scripting Host" error?
|
|
|
|
« Last Edit: November 01, 2009, 11:36:48 PM by Star-Fire »
|
IP logged
|
I'm bad English
|
|
|
gh0std0g74
Thanked: 37 Posts: 590
|
 |
« Reply #24 on: November 01, 2009, 11:33:59 PM » |
|
see post #20 again !!!!
|
|
|
|
Star-Fire Topic Starter
Posts: 13

|
 |
« Reply #25 on: November 01, 2009, 11:52:54 PM » |
|
Thanks your help. I need use cscript //nologo scriptname.vbs > file.txt before run your vbs I have output file, but I don't want it print each line on each window
|
I'm bad English
|
|
|
|
|
Star-Fire Topic Starter
Posts: 13

|
 |
« Reply #27 on: November 03, 2009, 12:32:01 AM » |
|
"scriptname.vbs" I know it is name my script, "WScript.Echo" will print all line when I run script. One window "Window Script host" will open with each line, I need choose "enter" per each (I can't do it with 3000+ line). I want stop it when i have output File
|
I'm bad English
|
|
|
|
|
gh0std0g74
Thanked: 37 Posts: 590
|
 |
« Reply #29 on: November 03, 2009, 04:21:41 AM » |
|
use cscript.exe not wscript.exe to interpret the file.
its so bizarre. i remember i did use cscript.exe, not wscript.exe.
|
|
|
|