need someone to complete within 20 hours

Running head: Automatic file transer 0

Introduction

Student Name

Comp 230

DeVry University

Professor: Charlotte McKenzie



Table of Contents

Introduction 4

Description of Project 4

Source Code 6

Output with Screen Shots 10

Conclusion 12

References 13

Table of Figures

Figure 1 Showing File MyData on F: 10

Figure 2Showing C: before program execute 10

Figure 3Execute program 11

Figure 4Showing new file created 11

Figure 5Showing File was successfully copied 12

Introduction

For this course project, the manager of a company has asked the team to study and explore a task perform by a system administrator. Then create a VBScript to automate the task that was researched and provide sample output runs with a description of it. The task that was chosen to automate is,copying files and folders from one place to another on a daily or weekly basis. (“10 System Administrator.”(2010))

Description of Project

The project must include at least five of the six topics listed below.

  1. VBScript Introduction: Variables, Constants, and Data Types

  2. VBScript Output Methods, VBScript Input Methods

  3. VBScript Decision-Making Statements

  4. VBScript Loop Structures and Arrays

  5. VBScript Procedures and Functions

  6. VBScript File Input/Output Methods

The following Script will allow the user to select which folder to copy and even select which files not to copy in the folder and copy the selected folder to a new folder. If the few folder doesn’t exists then the program will create the folder then copy the old folder into the new one.


Source Code

' VBScript: File_Transfer.vbs

' Date: 2/12/17

' Class: Comp 230

' Professor CAM

' ===============================

Option Explicit

Dim objFSO, strSourceFolder, strDestFolder, strExclusion, strPrompt

Set objFSO = CreateObject("Scripting.FileSystemObject")

strSourceFolder = "F:\MyData"

strDestFolder = "C:\MyBackupData"

strExclusion = "" ' Example: zip,vbs,exe,js,rar

If IsNoData(strExclusion) Then strExclusion = "" 'Make sure it is blank.

'Call function that will copy folder structure as well as files in it.

CopyFolderStructure strSourceFolder, strDestFolder, strExclusion

Function CopyFolderStructure(strSource, strDestination, strExcludedExt)

Const OVER_WRITE_FILES = True

Dim objDir, objFolder, objFiles, strCurExt, intX, arrExt, blnExclude

'Connect to the current directory in strSource.

Set objDir = objFSO.GetFolder(strSource)

'If destination folder doesn't exist, create it.

If Not objFSO.FolderExists(strDestination) Then

objFSO.CreateFolder(strDestination)

End If

'If current folder doesn't exist under destination folder, create it.

If Not objFSO.FolderExists(strDestination & "\" & objDir.Name) Then

objFSO.CreateFolder(strDestination & "\" & objDir.Name)

End If

'Validate if there is something in strExcludedExt.

If Not IsNoData(strExcludedExt) Then

'If yes, transfer content from strExcludedExt in an array.

arrExt = Split(strExcludedExt, ",")

blnExclude = False 'Intialize to False blnExclude

End If

'Loop through all files in current folder if any and copy all files in destination folder

'except for excluded extension if any in strExcludedExt.

For Each objFiles In objFSO.GetFolder(strSource).Files

If objFiles.attributes and 32 Then ' Check if the Archive Atrtibut Is set

'If there is exclusion, will compare if current extension file is excluded or not.

If Not IsNoData(strExcludedExt) Then

strCurExt = objFSO.GetExtensionName(objFiles.Name) 'Take current extension.

'Loop through the array to find if current extension has to be copied or not.

For intX = 0 To UBound(arrExt)

If LCase(strCurExt) = arrExt(intX) Then

blnExclude = True 'If found, set to True blnExclude and exit for.

Exit For

Else

blnExclude = False

End If

Next

If Not blnExclude Then 'If blnExclude is True, current file will not be copied.

objFSO.CopyFile strSource & "\" & objFiles.Name, strDestination & "\" & objDir.Name & "\" & objFiles.Name, OVER_WRITE_FILES

objFiles.attributes = objFiles.attributes - 32

End If

Else 'If no exclusion, copy everything in all folders/subfolders

objFSO.CopyFile strSource & "\" & objFiles.Name, strDestination & "\" & objDir.Name & "\" & objFiles.Name, OVER_WRITE_FILES

objFiles.attributes = objFiles.attributes - 32

End If

End If

Next

' If there is subfolder(s) under current folder in strPath, Call

' recursively this sub until there is no other subfolder(s)

For Each objFolder In objFSO.GetFolder(strSource).SubFolders

CopyFolderStructure objFolder.Path, strDestination & "\" & objDir.Name, strExcludedExt

Next

End Function

Function IsNoData(varVal2Check)

'Verify if varVal2Check contain something.

On Error Resume Next

If IsNull(varVal2Check) Or IsEmpty(varVal2Check) Then

IsNoData = True

Else

If IsDate(varVal2Check) Then

IsNoData = False

Elseif varVal2Check = "" Then

IsNoData = True

ElseIf Not IsObject(varVal2Check) Then

IsNoData = False

Else

IsNoData = False

End If

End If

End Function

Output with Screen Shots

need someone to complete within 20 hours 1

Figure 1 Showing File MyData on F:

need someone to complete within 20 hours 2

Figure 2Showing C: before program execute

need someone to complete within 20 hours 3

Figure 3Execute program

need someone to complete within 20 hours 4

Figure 4Showing new file created

need someone to complete within 20 hours 5

Figure 5Showing File was successfully copied

Conclusion

This course project is a teaching tool to help students learn the basics of how to create a simple program from scratch using VBScript and to make sure it works. The lessons learned here can be transferred over to a real life/job situation if needed. However, most big companies who stay up to date and modernized already have this figured out. With that being said, it is still very important to know and understand how to do this so that you can modify or fix a pre-existing program or even write a new one to replace the current one.

References

10 System Administrator Tasks Ripe for Automation. (2010). Retrieved from http://www.serverwatch.com/trends/article.php/12128_3908326_2/10-System-Administrator-Tasks-Ripe-for-Automation.htm

Complete Proposal Grading Rubric:

Category

Points

Points

Earned

Description

 Documentation and Formatting

 20

20 

 A quality paper will be free of any spelling, punctuation, or grammatical errors.
A quality paper will include a title page, appropriate sections based on a table of contents (TOC), an abstract or executive summary, proper citations, and a bibliography.
It will conform to APA guidelines; including citations and references. 

 Organization and Cohesiveness

 20

20 

 A quality paper will include an introduction based on a well-formed thesis statement. The logical order of the paper's content will be derived from the thesis statement.
Sentences and paragraphs will be clear, concise, and factually correct. The content will be properly subdivided into sections derived from the outline/TOC.
In a quality paper, the conclusion will summarize the previously presented content and will complement the thesis statement from the introduction.

Content

 100

100

 

The complete proposal should include the following.

  • Introduction

  • Description of program (script)

  • Source Code with detail comments

  • Source Code should contain a minimum 5 out of 6 topics learned during this session.

  • Explain the output along with screenshots of the output

  • Conclusion

Total

 140

140

A quality paper will meet or exceed all of the above requirements.