A little Python script, here named fileMoveScript.py, will do the renaming part of the job for you, Do you understand what the script will do? Make sure you do! Use nano and create the script yourself. Type it in and save it to a file called fileMoveScript.py in the directory ~/chromatograms. It is not necessary to type in the comment lines (the ones starting with a #, except the first one) if you don’t want to. Make sure you make the script executable with chmod as shown above. Do you understand what chmod does? What happens on the line with #!/usr/bin/python? Now use the script to rename the forward primer files. Also rename all the reverse primer files and give them a suffix. Create the dirAll “.rev” directory and move all the renamed files into this directory. There you have it! All 200 files renamed according to the correct naming convention and all in the same directory. You can now do the analysis for your boss. She will be very impressed with your work…! Actually, put the directory dirAll with all the files in it in a tarball. Call it fixedChroms.tar. Then gzip it and copy it back to a local disk on your laptop. Make sure you are able to do this! You can e-mail it to the engineer in Bali if you feel like it… Here we did tar without the = option and with that will a “-v” “verbose” “-c” “create” new tarball. Some comments to this exercise: This was an example of a task that is very time consuming, exceptionally boring and error prone if you do it for example by clicking, “manually”, dragging and typing in a GUI interface like Microsoft Windows. However, the task is very simple, quick, and potentially error free if you know a little bit of programming. We wrote a short script that did all the renaming, but did the creation of a new directory and moving of files into that directory with Unix commands on
A little Python script, here named fileMoveScript.py, will do the renaming part of the job for you, Do you understand what the script will do? Make sure you do! Use nano and create the script yourself. Type it in and save it to a file called fileMoveScript.py in the directory ~/chromatograms. It is not necessary to type in the comment lines (the ones starting with a #, except the first one) if you don’t want to. Make sure you make the script executable with chmod as shown above. Do you understand what chmod does? What happens on the line with #!/usr/bin/python? Now use the script to rename the forward primer files. Also rename all the reverse primer files and give them a “.rev” suffix. Create the dirAll directory and move all the renamed files into this directory. There you have it! All 200 files renamed according to the correct naming convention and all in the same directory. You can now do the analysis for your boss. She will be very impressed with your work…! Actually, put the directory dirAll with all the files in it in a tarball. Call it fixedChroms.tar. Then gzip it and copy it back to a local disk on your laptop. Make sure you are able to do this! You can e-mail it to the engineer in Bali if you feel like it… Here we did tar without the “-v” = “verbose” option and with “-c” that will “create” a new tarball. Some comments to this exercise: This was an example of a task that is very time consuming, exceptionally boring and error prone if you do it “manually”, for example by clicking, dragging and typing in a GUI interface like Microsoft Windows. However, the task is very simple, quick, and potentially error free if you know a little bit of programming. We wrote a short script that did all the renaming, but did the creation of a new directory and moving of files into that directory with Unix commands on
Unix2-Exercise-15.docx