Re: How to Return Filename in particular folder by JakeDAHS
JakeDAHS
Mon Jan 03 16:39:01 CST 2005
Sorry not quite feeling up to par today.
Chaning
oFSO.MoveFile sFileName, sTargetPath
to
oFSO.MoveFile "c:\origin\" & sFileName, sTargetPath
should fix that. a better way would be to find the full path for
sFileName as use that rather than just the filename
It will also work ok the way it currently is if the scripts resides in
the c:\origin\ folder
-Jake
mtech1@yadtel.net wrote:
> Thanks for the code, it really helps!
>
> I am new to scripting (1st attempt), I've been using VBA with MS
> Access.
>
> I'm getting an error on line 36:
> oFSO.MoveFile sFileName, sTargetPath
>
> Char:1, Error: File Not Found, Code: 800A0035, Source: MS VBScript
> Runtime Error
>
> I created folders (C:\Origin & C:\Origin2) and placed a file
> (Test12.xml) in C:\Origin.
>
> Then run the script and received the above error. I have looked
> through the script but cannot spot the problem. The original xml
file
> could have any name but will be a .xml file.
>
> Any and All Help Is ALWAYS Truly Appreciated!
> Dale
>
>
> JakeDAHS wrote:
> > This may not be the best but its late...
> >
> > '**************************************************
> > 'Author: jakedahs
> > 'Date: 1/2/2005
> > 'Name: script1
> > 'Version: 1.0.0
> > 'Use:
> > '
> > 'Revisions:
> > '**************************************************
> > 'Option Explicit
> > 'On Error Resume Next
> >
> > Const ForReading = 1
> > Const ForWriting = 2
> > Const ForAppending = 8
> >
> > Dim oFSO, oFile
> >
> > sTime = Replace(Time,":","-")
> > sTime = Replace(sTime," ","-")
> > sDate = Replace(Date,"/","-")
> > sTargetPath = "C:\Origin2\" & sDate & "-" & sTime & ".xml"
> >
> >
> > Set oFSO = CreateObject("Scripting.FileSystemObject")
> > Set oFolder = oFSO.GetFolder("c:\Origin")
> > Set colFiles = oFolder.Files
> >
> > For Each oFile in colFiles
> > sFileName = oFile.Name
> > If Instr(uCase(sFileName),"XML") <> 0 Then
> > oFSO.MoveFile sFileName, sTargetPath
> > Wscript.Echo "File " & sFileName & " moved to " & sTargetPath
> > iVar = 1
> > Exit For
> > End If
> > Next
> >
> > If iVar = 0 Then
> > Wscript.Echo "XML file not found"
> > End If
> >
> > Set oFolder = Nothing
> > Set oFSO = Nothing