Create a VBScript script (w3_firstname_lastname.vbs) that takes one parameter (folder name) to do the following
1) List all files names, size, date created in the given folder
2) Parameter = Root Folder name - The script should check and validate the folder name
3) Optionally, you can save the list into a file “Results.txt” using the redirection operator or by creating the file in the script.
4) Make sure to include comment block (flowerbox) in your code.
5) Sample run:- C:\entd261>cscript.exe w2_sammy_abaza.vbs "c:\entd261" >results.txt
Answer:
Please find below the required code in VBScript. I have also finished the optional part of storing the details in Results.txt. Please refer to the output snapshots and the comments in the code to understand the logic of each statement. However, as per your requirement of comment block. The same is not possible to do in vbs. VBS only supports single line comments. So I have written comments using the same. I have converted and printed the size in KB instead of bytes so that should give you more poitns. The output will be printed with proper indentation as a table. Thanks. :)
PS: If you are satisfied with the answer, please take a couple of seconds to rate the answer. Thanks. If you do have any questions/comments, do let me know. I will be glad to help. :)
Code:-
'Check if the user has not given any arguments. Print the
message and exit
if (WScript.Arguments.Count = 0) then
WScript.Echo "Missing parameters"
else
'Declare the File System object to be used
Dim fso
'Declare the path variable to be used for storing the path entered
by user
Dim path
'Create the File System object using the FileSystemObject
class
Set fso = CreateObject("Scripting.FileSystemObject")
'initialize the path
path = WScript.Arguments(0)
'Check if the path exists
exists = fso.FolderExists(path)
if (exists) then
'declare a constant of size 1024 since 1024 bytes = 1
Kb
CONST bytesToKb = 1024
'Print the selected path
WScript.Echo "Selected Path " &
WScript.Arguments(0)
'get the folder on path
Set inDir=fso.GetFolder(path)
'Create the file to store the output results
Set outFile =
fso.CreateTextFile("Results.txt",True)
'Print the name, date created and size of each file and
store the same in output file
For Each objFile in inDir.Files
'Calculate the padding needed for File Name.
Assuming the maximum length of file name is 40 characters
namePadding = 40 - Len(objFile.Name)
'Calculate the padding needed for Date
datePadding = 30 - Len(objFile.DateCreated)
'Add spaces to file Name so that same can be
printed in a tabular format
fileName = objFile.Name &
Space(namePadding)
'Add spaces to date so that same can be printed
in a tabular format
dateCreated = objFile.DateCreated &
Space(datePadding)
'Print the details on screen
Wscript.Echo fileName & dateCreated &
CINT(objFile.Size / bytesToKb) & "Kb"
'Store the details in ouput file with a newline
character at the end
outFile.Write fileName & dateCreated &
CINT(objFile.Size / bytesToKb) & "Kb" & vbCrLf
Next
'Close the output file once the loop ends
outFile.Close
else
'Print a message if the path does not exist
WScript.Echo "Invalid Path Entered"
end if
end if

Output:
Command Prompt
Results.txt

Create a VBScript script (w3_firstname_lastname.vbs) that takes one parameter (folder name) to do the following 1)...
Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file, "insert-user-form.php", with a form that has the following fields: - First Name (text) - Last Name (text) - Email (text) - Password (text) - Submit button Create another PHP file, "insert-exercise-form.php" with a form that has the following fields: - Exercise Name (text) - Description (text) - Demonstration Image (file) - Submit button Create another PHP file, "login-user-form.php" with a form that has the...
Write a script named listEmptyDir.sh that will do the following: (a) take a name of a directory as a parameter; (b) loop through all files in this directory and display their names; (c) if a file is a directory and has no files in it (empty directory), add the name of this empty directory to the file EmptyDir.txt in your current directory. If the number of parameters is not 1 or a parameter is not a directory, display the “usage”...
(In Linux) 1. Create a file to write to from your script and save it as “.txt”. 2. Write the following information to the file that you created in Step 1: Today's date Your full name Your student ID The name of your course What directory you are in File permissions of the file that you created that allow everyone to read, write, and execute The long list of files in your current directory, providing all items and their process...
Problem 1 Write a BASH script to create a user account from the Linux system on which your script is run. The script should process two positional parameters. First positional parameter is supposed to be a string with a user name (e.g., user_name) Second positional parameter is supposed to be a string with a user password (e.g., user_password) In your script: Check if two positional parameters were passed to your script when it was invoked If NOT, print an appropriate...
Part 1: Create a shell script that returns a full name associated with a userid specified in the command line argument. • Use the names found in /acct/common/CSCE215-Spring19. • Your shell script should be named “findName.sh” – Example usage: $ ./findName.sh seiei SETSUNA F SEIEI $ – Your shell script must either: Return the full name associated with the userid or Return an error message if the command line arguments are not equal to 1. or Return the message “Sorry...
Create a bash script to do the following on your CentOS6 VM. To back up your home folder using tar command daily. Use gzip as the compression for tar (z option). – 10pts Hint: Make sure you exclude the tar file itself from the backup. The script should name the tar file backupYYYYMMDD.tar.gz -10 pts The script should keep the last seven days of backup files and delete backup files older than seven days. -10 pts The script should check...
Task 2.6 : In this exercise, you will create a script to echo users, based on a list of usernames in a file. 1. create a new file called userlist. #vi userlist 2. Insert a short list of usernames, such as the following. Make sure that none are the names of existing users. moe larry curly binny 3. create a script file userscript.sh and type the following lines #!/bin/bash for TheUSER in $(cat userlist) do echo The user is $TheUSER...
This script will create a dictionary whose keys are all the directories listed in thePATH system variable, and whose values are the number of files in each of these directories. The script will also print each directory entry sorted by directory name. The script will use the following five functions to get the required results get_environment_variable_value() get_dirs_from_path() get_file_count() get_file_count_for_dir_list() print_sorted_dictionary() get_environment_variable_value() The header for this function must be This function must accept a shell variable as its only parameter The...
Unix Debian System Create a script with the following functionality: a. (3 points) The script takes a list of users from standard in. Note: this implies the script will be executed as follows: cat /root/users | ./script.bash and the file that contains a list of users is a list with a one user per line b. (3 points) Before removing each user, you need to ensure the user exists (hint: use this $(cat /etc/password | egrep “^$username”) and see if...
Exercise: (2) Create a class called Dog containing two Strings: name and says. In main(), create two dog objects with names “spot” (who says, “Ruff!”) and “scruffy” (who says, “Wurf!”). Then display their names and what they say. Be sure to use setter and getter methods to assign(set) and retrieve(get) values for both Strings name and says. Your Task: Create the program using Netbeans and easyUML (i.e: Open a project in NetBeans then create the classes, attributes, and methods in...