There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Tag Cloud
access acer asus bios bsod computer crash dns drive driver drivers error ethernet excel freeze games gaming graphics hard drive hardware hdmi internet java laptop malware memory monitor motherboard network printer problem ram random registry router slow software sound trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > General Technology > Tech Tips & Tricks >
Solved: script question, suggestions needed...

Reply  
Thread Tools
slafta's Avatar
Junior Member with 3 posts.
 
Join Date: Aug 2008
02-Dec-2008, 11: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 at 01:19 AM..
slafta's Avatar
Junior Member with 3 posts.
 
Join Date: Aug 2008
03-Dec-2008, 02: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
Reply

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.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:06 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.