Script to Archive Files, needs to verify that file with same name does not exist in destination.
Posted on 2006-04-13
I do OK with shell scripts but I'm so new to VB I will claim no knowledge. Have been tasked to come up with a solution. I found the following and works well, but..... blows up if a file with the same name exists in the destination. What I need is for the script to check for the existence of same filename in destination before move, if found append a 1,2,3,4.... to the file name until can successfully move. Also would be good if it created a log file. Thanks for your help in advance!
'generic move files :
Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("e:\out")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateCreated, Now) > 30 Then
fso.MoveFile f1 , "e:\in\"