Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Thu, 3 Jul 2008 00:04:10 -0700 (PDT),    group: microsoft.public.inetsdk.programming.scripting.vbscript        back       


Reading filename from a file   
I have a file "tmp.txt" in a format like

word0, c:\1.txt
word2, c:\2.txt
word4, c:\Copy of tmp1.txt

I need to delete all the files listed in 2nd column.

I tried this script.



Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\tmp.txt", ForReading)
Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , ",")
    Wscript.Echo "File Name to be deleted  :  " & arrServiceList(1)
    strFilePath = "arrServiceList(1)"
    set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.DeleteFile(strFilePath)
Loop



It gives me Error  on line "objFSO.DeleteFile(strFilePath)"

File Not found.

This is my first script.
Please help

Kuldeep
date: Thu, 3 Jul 2008 00:04:10 -0700 (PDT)   author:   Kuldeep

Re: Reading filename from a file   
Thanks to Bishop I found the solution.

http://groups.google.co.in/group/microsoft.public.scripting.vbscript/browse_thread/thread/1014fb5ce4294acf?hl=en#

Kuldeep


On Jul 3, 12:04 pm, Kuldeep  wrote:
>  I have a file "tmp.txt" in a format like
>
> word0, c:\1.txt
> word2, c:\2.txt
> word4, c:\Copy of tmp1.txt
>
> I need to delete all the files listed in 2nd column.
>
> I tried this script.
>
> Const ForReading = 1
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.OpenTextFile("c:\tmp.txt", ForReading)
> Do Until objTextFile.AtEndOfStream
>     strNextLine = objTextFile.Readline
>     arrServiceList = Split(strNextLine , ",")
>     Wscript.Echo "File Name to be deleted  :  " & arrServiceList(1)
>     strFilePath = "arrServiceList(1)"
>     set objFSO = CreateObject("Scripting.FileSystemObject")
>     objFSO.DeleteFile(strFilePath)
> Loop
>
> It gives me Error  on line "objFSO.DeleteFile(strFilePath)"
>
> File Not found.
>
> This is my first script.
> Please help
>
> Kuldeep
date: Thu, 3 Jul 2008 04:54:03 -0700 (PDT)   author:   Kuldeep

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us