‘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

 

About Lei

I am an IT specialist with over 10 year experience - years on Automation, on-Premise or Azure.

I am happy to develop however never want be a full time developer. Only do what I have to do. If it has to be PowerShell,HTML, PHP, CSS, C#, VBS or JS, front end or backend, so be it, doesn't matter!

Spent years with Windows, SCCM, SharePoint, SQL and Exchange servers. For last several years, I have been actively working under On Premise > Azure environment.

THERE IS NO WAY BACK!!!

Current Certificates:
    Microsoft® Certified-
  • -Enterprise Administrator
  • -Database Administrator
  • -SharePoint Administrator
  • -Administering and Deploying SCCM 2012
Red Hat Certified Technician
ITIL V3 Foundation - Practitioner

Working on Azure Certificates now and hopefully they can stop upgrading their questions one day! GIVE ME A BREAK!

Contact Lei

Name *
Email *
Comments *

Traffic since 10/08/2016

Today45
Yesterday83
This week669
This month1965
Total416325

Visitor Info

  • IP: 54.163.210.170
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

2
Online

2017-12-17

Login