?
Solved

output exception to txt file

Posted on 2007-11-21
7
Medium Priority
?
393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 20329997
>' 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
ID: 20330201
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
ID: 20330215
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20330227
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
ID: 20330344
>>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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20330361
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
ID: 20330442
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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