Code Help
A fellow faculty member sends me this request to help her write a script for her class since I have written script for her previously for her this one in ? is way out of my league and am looking for some great help from you all.
Your dear friend Edwina would like an interactive file copy utility created. Since Edwina knows you are the master of the command line script file, she has come to you for a solution. She would like the command line to require the source folder to be entered with the command name. The existence of a command line parameter and the existence of the folder itâs supposed to represent should be checked. The script should then prompt the user for the name of the file that is to be copied from that folder. Check to make sure the file entered exists in the folder. If it does not, warn the user and ask if they want to copy another file. If they say no, display the results outlined below and quit. If they say yes, loop back and get another file name. Once the existence of the file within that folder is verified, the script should prompt the user for a destination folder. If the folder does not exist, the script should prompt the user asking if the folder should be created. If the user says no, nothing more should be done for that file. If the user says yes, the new folder should be created and the file should be copied. If the folder does exist, the script should check to see if the file is already in that folder. If it isnât, just copy the file to the folder. If the file does exist, ask the user for permission to overwrite it. If they say yes, overwrite the file. If they say no, do nothing with that file. Regardless of whatâs been done with the file, you should ask the user if they would like to copy another file from the folder. If they say yes, loop back and ask for another file name. If they say no, display a count of the number of files that were copied and the number of folders that the command created. The syntax you and Edwina finally agreed upon is shown below.
icopy source_folder
i.e.,
icopy c:\myfolder\data
Once icopy starts execution, it should first check for the existence of the folder c:\myfolder\data. A flowchart is attached at the end of this document to help you with the logic.
|