[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

output exception to txt file

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
James Rodgers
Asked:
James Rodgers
  • 4
  • 3
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>' 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
 
James RodgersWeb Applications DeveloperAuthor Commented:
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
 
James RodgersWeb Applications DeveloperAuthor Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
James RodgersWeb Applications DeveloperAuthor Commented:
>>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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
glad I could help!
sorry for that, was actually intended "jokeful", looks like that did not get through ...
0
 
James RodgersWeb Applications DeveloperAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now