Making batchfile tools

In these exercies you will learn how to use some useful DOS programs together with batchfiles.

At the end of lecture 3 you'll find instructions for using the programs and you can also use the helps of the programs.

  1. Write a batchfile that copies all files with the postfix .cpp, .doc and .xls from a floppy disc to a corresponding directory hierarchy on the hard disc. This batchfile is useful for example in transferring files from computer lab to your own computer. Copying individual files on Windows can be an annoying exercise. When writing the file pay attention to this:

    Save the batchfile as harddisc.bat and test it.

    An example: harddisc   U:\systems\
  2. Write another version that copies the files from a directory on the hard disc to a floppy disc. Otherwise the batchfile should be as the one above.
    An example: tofloppy U:\systems\

    What problems there might be with using the batchfile? How would you solve them?

  3. Get a DOS based anti-virus program to your computer from <URL: ftp://ftp.europe.f-secure.com/anti-virus/free/>. The program file is a zip file called fp-308.zip. Save it to U:\systems\. Now let's write some batchfiles that make it easier to unzip and use the anti-virus program.

  4. The first job is to unzip the program file by using a DOS based program pkunzip. By writing the name of the progran on the Command Prompt you'll get the help for the program. A brief instruction for using PKZIP and PKUNZIP is available at the end of lecture 3.

    Write a batchfile for unzipping. By using this batchfile you don't have to remember the parameters for the program every time.

    An example: unzip  fp-308.zip   fprot
    
  5. The anti-virus program can be used in the DOS user interface but in the following you will use the program straight in the Command Prompt.

    Write a batchfile that deletes viruses without asking the user for confirmations. Help for F-prot parameters is available by using the command f-prot /?.

    The batchfile above is useful when you give an anti-virus program to a friend who knows nothing about it.

    An example: scan
  6. Now you have a batchfile you can give for you friends to use. The batchfile has to be in the same package as the anti-virus program. The program is too large for one floppy disc so it has to be packed on several ones. This time we use the ARJ programme for compressing.

    Write a batchfile that compresses the files and subfolders in a directory given as a parameter and makes floppy disc sized packages of them. Then it is easy to copy the compressed files to a floppy disc. By writing the name of the ARJ program on the Command Prompt you'll see the help for the program. Brief instrucions for using ARJ is found at the end of leture 3.

    An example: compressARJ  file_or_directory
    
  7. Write a batchfile that uncompresses the packages. Save it as uncompressARJ.bat.

    An example: uncompressARJ package
    

    On the last disc there is usually space for the batchfile and you may also need to include ARJ. You can also write short instructions and include them in the disc:

  8. If you repeatedly copy files between your computer and a server you can make it easier by writing a batchfile for it and by saving it to the U: drive.

    Plan and write a batchfile for copying files between a server and your computer. Note that usernames and passwords must never be asked on a batchfile!. For brief instrictions for using SCP see the end of lecture 3.

    An example: copy_p2c   server_directory  local_directory
    
  9. Are the batchfiles you wrote of any use for you? Can you think of a situation where you could use them?

http://
© Petri Heinonen ()<URL: http://www.mit.jyu.fi/peheinon/>