backup vbscript from .txt

April 14, 2009 at 05:30:00
Specs: Windows XP
HI

Need a little help with a some vbscipt. I need a function that will read a specific .txt file that has a list of files of certain type (.doc, and .mp3) and check to see if an backup is nessesary. This .txt file has been created from this previously called function:

Function CheckFolder(objCurrentFolder)
Set oFolder = fso.GetFolder(objCurrentFolder)
For Each oFile In oFolder.files
If oFile.Extension = "txt" OR "doc" Then
Set objFiletxt = objfso.CreateTextFile("i:\search_results.txt", True)
objFiletxt.WriteLine(objFile)
End If
Next
For Each objNewFolder In oFolder.subFolders
CheckFolder objNewFolder
Next
End
'code is untested at the moment as other functions are being made

If the files listed in the .txt file are already in the designated backup folder, and its modified date has not changed, then i want to remove the file listing from the .txt file.

I then want the remaining files in the .txt file to be copied to the designated backup folder.

i am only concerned with checking local hard drives and removeable media (eg - USB sticks) so network drives are not nessesary.

Feel free to make whatever changes you see fit for the code that I have supplied

Any help will be appreciated
Thanks




See More: backup vbscript from .txt

Report •


#1
April 14, 2009 at 07:12:46
I have since tested the given code and have run into some trouble. It doesent spit out an error but it does not create the .txt file either.
I have slightly modified it. I will require it to search through all local drvies in the final version.

Set objfso = CreateObject("Scripting.FileSystemObject")
Dim objFiletxt

objCurrentFolder = "c:\"
Function CheckFolder(objCurrentFolder)
Set oFolder = fso.GetFolder(objCurrentFolder)
For Each oFile In oFolder.files
If oFile.Extension = "txt" OR "doc" Then
Set objFiletxt = objfso.CreateTextFile("i:\search_results.txt", True)
objFiletxt.WriteLine(objFile)
End If
Next
For Each objNewFolder In oFolder.subFolders
CheckFolder objNewFolder
Next
End Function

Any help will be appreciated.

Thanks


Report •
Related Solutions


Ask Question