I fixed 2 things with these lines, 1) replaced filesys with fso, 2) added the sub folder name to the path.
I do have q question, regarding the dim and const, so if you use a const statement, you do not need a dim statement to hold the value?
I just need to figure out why it is not deleting files that are older then 7 days. I even rename the file name in If fso.FileExists("c:\DenServerBackup\Sunday\Sunday.bkf") Then, to this If fso.FileExists("c:\DenServerBackup\Sunday\SUNDAY20070111.bkf") Then
and still did not delete it, so I guess my problem is in this line of code:
Then maybe EBGreen can help me with the adding the date code to the file name to be checked, as my script looks for Sunday.bkf and not For SUNDAY20070111.bkf, and I do not even have a clue, about adding this to the vbs code.
Here is the fixed code:
Thanks,
Mike
< Message edited by netman06 -- 1/12/2007 4:52:43 AM >
to: CleanUpOldFiles oFSO.GetFolder(dicDays(strDay)), 7
I enjoy seeing how people like ebgreen, ehvbs, tno, and many more are able to streamline certain processes....I'm always learning something new from all of you.
< Message edited by dm_4ever -- 1/12/2007 5:29:25 AM >
Oops...thanks for the catch. My compiler-like brain is asleep at the wheel today. I apologize for the mistake, but I am not testing any of this code (busy day) and am basically just brain dumping it onto the page.
I do have a question, if I perform a full on mon, diffs, tue,wed, thur, fri, sat, sun. Shouldn't I have a maybe two. I was trying to figure this out earlier when I used 7 days, and I thought was better then giving it a full weeks worth of runs.
Any ideas
Thanks so much for all of your help, and like dm_4ever said, you can sure learn from people like you, even with you coding, I always look at how you do it, so next time I can look up the commands, which I helpful, but a lot of times, its really hard to put everything together, which I guess takes all of tweaking and reading posts, and helpful people like yourself and dm_4ever.
I transfered this script to Windows Server 2003, and now I'm receiving this error message.
It worked fine on Windows xp Service pack 2. I have look up error 800A0046, but have not found a solution.
Error is saying Permission denied, line 31 and Char 1. I have set every dir and file to administrator full control, with no luck. I know it has something to do with server 2003, but what.
That is one of the problems with complex lines like that. It is hard to determine exactly what instruction in the line causes the error. Try putting these lines right before the problem line to see if we can narrow down the error source.
still getting the same error message. What happens, different in Windows Server 2003 and Windows XP SP2, reference scripting and permissions, because it worked great on Windows XP, but not on Windows Server 2003?
I think I figure out the problem, it has something to do with the sourcedir line. I had it set to "G:\\", so I tried it with "G:\BackupTest\", and I did not get the error. I'll give you an update after somemore testing.
Your orignal line:
Const SOURCEDIR = "C:\Path\To\Dir\Den_Server_Backup\" 'Note the trailing \
EBGreen, I'm trying to get dm_4ever code to work with your code. I will first your your script, then run dm_4ever code, for deleting files older then seven days, but I do not have any idea how to work with the file names, because of the date include in the file name, I have tested it with just standard days of the week names, like monday, sunday, and it works, so how can it work with Friday20070118.bkf, if It is not possible, what if we used on the file extention, which we know, like is there a way to use just *.bkf.
Here is the code:
Thanks for all of your help today, trying to get this to work, it really must be a root drive thing on Windows server 2003?
If you having issues with IF End IF and Next, I would start by reading this great book. After an hour you will know exactly what ebgreen etc are writing
I have added the liines, but I'm getting an error message. 800A01C2, I looked it up and here is it said, regarding the error,
Troubleshooting Error 800A01C2 - Wrong number of arguments of invalid property assignment. Error 800A01C2 is a tricky problem. Check to see if your script needs an extra 'Set' Command Introduction to Code 800A01C2 Error code, 800A01C2 occurs when you execute a VBScript. This is a runtime error, therefore check the names of your objects. The Symptoms you get The script does not execute as you had hoped. Instead you get a message box like this picture: (If you have a better screen shot, then please email me.) The Cause of Code 800A01C2 The best clue to the error comes at the end of the line, the word 'objUser'. objUser is a valid object and term, therefore we need to investigate what is missing. I solved the problem by comparing with another script, which executed perfectly. It turned out that 'Set' was required in front of objUser. Incidentally, Source: reports a runtime error not a compilation error, this means you are looking not for a pure syntax problem, but a fault logic error. In the case of runtime errors, you can use this temporary work around. Add this statement just before the line which errors: On Error Resume Next. The Solutions Wrong number of arguments of invalid property assignment. Check the names in your script, pay particular attention to object names. Note: The Line: 6 Char: 1 In this case it is not Char 1 to blame, more that there is something wrong and none of the line can execute. In this case it should be Set objUser = As a last resort, in the case of runtime errors, you can add this line: On Error Resume Next.
EBGreen, I set a wscript.echo for the (strday), string but it contained a null value.
above this code
For Each strDay In dicDays.Keys() CleanUpOldFiles oFSO.GetFolder(dicDays(strDay), 7) Next
Error is on Line # 24 , Char 4
Wrong number of arguments or invaild property assignment: 'getfolder'
so if it needs a set command. so would this line need a set command.
For Each oFile In oFSO.GetFolder(SOURCEDIR).Files
Also, I pretty sure now that the script does work, now that I figure out the root drive issue.
Thanks again for all of your time you put into this script and giving me a opportunity to learn more about vbscripting, I know we are close now to figuring out a great script, the hopfully forums users can use for the same propise as me.