Solved

output exception to txt file

Posted on 2007-11-21
7
380 Views
Last Modified: 2010-04-24
I have some code that copies the latest file found in a directory, i have the code looking through a series of subdirectories to find the newest file and then if the file contains todays date in the name then move it to a new loc, but i need to know if one or more of the latest files is not from today then output the file information to a txt file as an exception

code below
function getParent()

	fPath="D:\mySQLBackup"

	Set oFSO = CreateObject("Scripting.FileSystemObject")

	Set oFolder = oFSO.GetFolder(fPath)

	set oSubfolders = oFolder.Subfolders

	

	for each oSubfolders in oSubfolders

		filePath=GetNewestFile(oSubfolders)

		if(instr(filePath, sToday)) then

			fileName = re.replace(GetFilenameFromPath(filePath),"")

			oFSO.CopyFile filePath , "D:\Backup\mySQLBackup\" & fileName , OverwriteExisting

		else

			 ' output data to "exception" & date() & ".txt"

		end if

	next 

end function

Open in new window

0
Comment
Question by:James Rodgers
  • 4
  • 3
7 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
>' output data to "exception" & date() & ".txt"

simply could be:


Set objTextFile = oFSO.OpenTextFile _

(fPath & "exception" & date() & ".txt", ForAppending, True)

objTextFile.WriteLine("output data")

objTextFile.Close

Open in new window

0
 
LVL 25

Author Comment

by:James Rodgers
Comment Utility
does the file need to exist or will this create it?
what happens on the next iteration when another exception is found? is it appended as a new line?
0
 
LVL 25

Author Comment

by:James Rodgers
Comment Utility
also, the code sample you have given wil put teh exception in the directory fpath, is there a system variable that will allow me to put it directly on teh desktop?


thanks
 
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
what do you think the following parameters of oFSO.OpenTextFile will do:
ForAppending, True

anyhow, to clear any doubts:
http://www.w3schools.com/asp/met_opentextfile.asp
0
 
LVL 25

Author Comment

by:James Rodgers
Comment Utility
>>what do you think the following parameters of oFSO.OpenTextFile will do:
i'm not sure that's why i ASKED, for clarification, yes the append is clear, but not knowing any vbs how am i supposed to know what the true does?...oh yes i ASKED and got a facetious response, thanks
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
glad I could help!
sorry for that, was actually intended "jokeful", looks like that did not get through ...
0
 
LVL 25

Author Comment

by:James Rodgers
Comment Utility
im sorry i took it the wrong way, i referenced this question to you as i respect your efforts on ee and i was a little shocked at the response

btw desktop variable
Set objShell = CreateObject("Wscript.Shell")
strFolder = objShell.SpecialFolders.Item("Desktop")

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now