Ayush
Mon Dec 11 16:33:07 CST 2006
cclg2@yahoo.com wrote:
> Not very far, I'm just learning vbscript. I guess it's time to find a
> tutorial on the subject.
> Thanks.
'- - - - - - - - - - - - - -
Set objF = CreateObject("Scripting.FileSystemObject")
IF objF.FileExists("C:\files\filename.txt") Then
If objF.FolderExists("C:\Archives\") Then
objF.CopyFile "C:\files\filename.txt",
"c:\archives\filename_20061211.dat"
End If
End If
'- - - - - - - - - - - - - -
Here is the explaination :
1. '- - - - - - - - - - - - - -
2. Set objF = CreateObject("Scripting.FileSystemObject")
3. IF objF.FileExists("C:\files\filename.txt") Then
4. If objF.FolderExists("C:\Archives\") Then
5. objF.CopyFile "C:\files\filename.txt",
"c:\archives\filename_20061211.dat"
6. End If
7. End If
8. '- - - - - - - - - - - - - -
1. Starting line so that you know where to start the script.
It is in comment so it will not hurt anything even if you
include this in script.
2. Create the FileSystemObject to work with Files/Folders
(Copy,Move etc ... )
3. Check if "C:\files\filename.txt" exists or not. If it
exists then run the next line, if it doesn't exists then End
the if statement and continue the rest of script.
4. Check if "C:\Archives" folder exists or not. This is a
big thing, the script will not automatically create the
folder if it doesn't exists so it is good thing to check
instead of getting an error. If folder exists then contine
the next line, if doesn't then End this If statement.
5. Main thing : After checking all folder/files exists, run
the Copy operation. .. .
6. End the if statement that checks the Folder existence.
7. End the if statement that checks the File existence.
8. Ending line so that you know where the script ends. It is
in comment so it will not hurt anything even if you include
this in script.
More Info about FSO (File SYstem Object ) :
http://classicasp.aspfaq.com/files/directories-fso/could-i-get-some-help-working-with-files-using-filesystemobject.html
Some great explanation and examples of FSO :
http://www.computerperformance.co.uk/ezine/ezine36.htm
FSO Object :
http://www.computerperformance.co.uk/ezine/ezine104.htm
--
Ayush [ Good :-) Luck ]
-------------
Search - www.Google.com | Wikipedia -
http://en.wikipedia.org
Snip your long urls -
http://snipurl.com/
-------------