Computing.Net > Forums > Programming > backup vbscript from .txt

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

backup vbscript from .txt

Reply to Message Icon

Name: Rooster99
Date: April 14, 2009 at 05:30:00 Pacific
OS: Windows XP
Subcategory: General
Comment:

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





Sponsored Link
Ads by Google

Response Number 1
Name: Rooster99
Date: April 14, 2009 at 07:12:46 Pacific
Reply:

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: backup vbscript from .txt

Read lines from .txt file in DOS? www.computing.net/answers/programming/read-lines-from-txt-file-in-dos/15219.html

Extracting data out from txt file www.computing.net/answers/programming/extracting-data-out-from-txt-file-/20329.html

Extract IP address from txt file www.computing.net/answers/programming/extract-ip-address-from-txt-file/13912.html