Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Tech Tips & Tricks
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor network networking outlook problem processor ram recovery router safe mode slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > General Technology > Tech Tips & Tricks >
Solved: script question, suggestions needed...

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
slafta's Avatar
Junior Member with 3 posts.
 
Join Date: Aug 2008
02-Dec-2008, 10:41 PM #1
Exclamation Solved: script question, suggestions needed...
I am writting some code to parse a directory contents into a text file, how ever here is my problem, since customer can modify to directories there are no static names. I was looking a vbs script solution to search a line with a text file and delete all text to the left of the '\' also this would have to be nested since each line could have multiple subdirectories, any ideas would be appreciated.


Thanks again for any input.


Modifed:
If I could find a way to read a text file, save the line into a string variable called current_line and then execute this segment and then write the modified current_line back into the original file at the same point.

here is the last code before i got stuck:::



fspec="list.txt"
set fso=createobject("scripting.filesystemobject")
set ots=fso.opentextfile(fspec)
do while not ots.atendofstream
s=ots.readline
'do thing with the info
dim Result
Result = InStrRev(s, "\")
s = Mid(s,(result+1))
ots.Write(s) 'problemed line thus far
'(10, 6) Microsoft VBScript runtime error: Bad file mode
loop
ots.close
set ots=nothing
set fso=nothing



this would work, thanks for your assistance...

Last edited by slafta : 03-Dec-2008 12:19 AM.
slafta's Avatar
Junior Member with 3 posts.
 
Join Date: Aug 2008
03-Dec-2008, 01:46 AM #2
Cool This is what i settled on:
Dim ArgObj, var1, var2
Set ArgObj = WScript.Arguments

'First parameter
var1 = ArgObj(0)
'Second parameter
var2 = ArgObj(1)
wscript.echo("Input Filename=" & var1 & " Output Filename="

& var2)

set fso=createobject("scripting.filesystemobject")

'OpenTextFile Parameters:
'-Filename
'-The 2 is for writing... 1 is reading and 8 is appending
'-The "True" is to create if not already there.

set input_file=fso.opentextfile(var1)
set output_file=fso.opentextfile(var2, 2, True)

do while not input_file.AtEndOfStream
s=input_file.readline
'ECHO FOR DEBUGGING ONLY---->wscript.echo(s)
'do thing with the info
dim Result
Result = InStrRev(s, "\")
'ECHO FOR DEBUGGING ONLY---->wscript.echo(Result)
s = Mid(s,(result+1))
'ECHO FOR DEBUGGING ONLY---->wscript.echo(s)
output_file.Write(s)
output_file.Write(vbCrLf)
loop
input_file.close
set input_file=nothing
set fso=nothing
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 03:02 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.