‘GetSubFiles.vbs

On Error Resume Next
Dim fso, folder, files, NewsFile,sFolder, nFile , CurrentTime

Set fso = CreateObject(“Scripting.FileSystemObject”)
sFolder = Wscript.Arguments.Item(0)
If sFolder = “” Then
Wscript.Echo “No Folder parameter was passed”
Wscript.Quit
End If

Set folder = fso.GetFolder(sFolder)
CurrentTime = year(now)&Right(“0″&month(now),2)&Right(“0″&day(now),2)&hour(now)&minute(now)&second(now)
Set LogFile = fso.CreateTextFile(sFolder&”\”& folder.name&”_” & CurrentTime & “.log”, True)
Set files = folder.Files
For each folderSub In folder.SubFolders
For each subFiles In folderSub.files
if inStr(folderSub.Name, “resource”) Then
Wscript.echo(subFiles.Name & ” is under ” & folderSub.Name&”, so it is not considered to copy”)
LogFile.writeLine (“[NORMAL] “& subFiles.Name & ” is under ” & folderSub.Name&”, so it is not considered to copy”)
else
if inStr(subFiles.Name, “Marked”) Then
Wscript.echo(subFiles.Name&” is marked already, so it is not considered to copy”)
LogFile.writeLine (“[NORMAL] ” & subFiles.Name&” is marked already, so it is not considered to copy”)
else
Wscript.echo ( “Now start moving file ” & subFiles.Name & ” under ” & folderSub.Name   )
nFile= folderSub.Name & “_” & subFiles.Name
fso.MoveFile subFiles.path,”collection\” & nFile
Wscript.echo ( nFile & ” now has been collected”)
LogFile.writeLine (“[NORMAL] ” & nFile & ” now has been collected”)
End if
End if
Next
Next
LogFile.Close
On Error Resume Next
Dim fso, folder, files, NewsFile,sFolder, nFile , CurrentTime, studFolder, studFile, mstr

Set fso = CreateObject(“Scripting.FileSystemObject”)
sFolder = Wscript.Arguments.Item(0)
If sFolder = “” Then
Wscript.Echo “No Folder parameter was passed”
Wscript.Quit
End If

Set folder = fso.GetFolder(sFolder)
CurrentTime = year(now)&Right(“0″&month(now),2)&Right(“0″&day(now),2)&hour(now)&minute(now)&second(now)
Set LogFile = fso.CreateTextFile(sFolder&”\”& folder.name&”_” & CurrentTime & “.log”, True)
For each Mfile In folder.Files
if inStr(Mfile.Name, “_”) Then
mstr= inStr(Mfile.Name, “_”)
studFile= Right(Mfile.Name, Len(Mfile.Name)-mstr)
studFolder = Left(Mfile.Name, mstr-1)
Wscript.echo ( “Now send back marked file ” & studFile & ” to its folder ” & studFolder   )
fso.MoveFile Mfile.Path, “..\..\”& studFolder & “\Marked_”& studFile
Wscript.echo (Mfile.Name & ” now has been send back”)
LogFile.writeLine (“[NORMAL] ” & Mfile.Name & ” now has been send back”)
End If

next

LogFile.Close

 

 

 

Advertisements