Bash shell scripting. To take 2 basic scenario questions and create 2 bash scripts. Explain each line of code with # marks for future study of the code. If you cannot complete this in 2 days then dont bid on the job.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
#1 You've just loaded a CD's worth of reference images from an outside company. The images follow a naming scheme such as [login to view URL], [login to view URL] ... [login to view URL], although the frame numbers may be noncontiguous (i.e., there may be gaps between numbers).
Although the frames were stored in separate directories on the CD-ROM from which they were loaded, all of the frames have now been placed into this directory: /shots/mytechsource/home/pix/out/home_test_v1/misc_bg8 The structure of the directory you've loaded them into is this:
/shots/$SHOWNAME/$SHOTNAME/pix/out/$ELEMENTNAME/$RESOLUTION_$COLORSPACE Your task is to rename the frames in accordance with mytechsource standard naming conventions. These include:
1. No capital letters in the filenames
2. No dashes allowed in the filenames
3. The images should be re-numbered so that they are a contiguous sequence (i.e. no gaps)
4. Frame numbers need to be padded to four-digits. ie, "1" becomes "0001" This is denoted by the symbol # so a range of 1-240 would read 1-240#.
5. The frames should be renamed to match the directory in which they are placed in the following manner:
$ELEMENTNAME_$RESOLUTION_$COLORSPACE.#.$EXTENSION So, in other words, each frame should become:
/shots/mytechsource/home/pix/out/home_test_v1/misc_bg8/[login to view URL]
/shots/mytechsource/home/pix/out/home_test_v1/misc_bg8/[login to view URL]
/shots/mytechsource/home/pix/out/home_test_v1/misc_bg8/[login to view URL] ...
/shots/mytechsource/home/pix/out/home_test_v1/misc_bg8/[login to view URL] However, the incoming frames are part of a series and must be kept in the exact same order as they were when loaded (i.e., the incoming frame with the lowest index will map to `[login to view URL]', while the second lowest index will map to `[login to view URL]', and so on). Hint:sorting by name is not enough!
Write a script called `mytechsource_cd2spi' that takes a single argument which will be the directory containing the images described above. Use the current working directory if no argument is provided. Your script should then rename all of the images in that directory to match mytechsource naming conventions.
Sample usage:
$ mytechsource_cd2spi /shots/mytechsource/home/pix/out/home_test_v1/misc_bg8 Please name the attachment for question 1 results: mytechsource_cd2spi
#2 At mytechsource we often use a command-line tool named "itstat" which will display the resolution of an image file and some other lines of information. It accepts a list of image files as arguments (i.e., "itstat FILE1 FILE2 ..."), and its output looks like this:
File: [login to view URL]
Resolution: 720 x 547
Channels: 3
Channel Types: RGB without Alpha
Bit Depth: 8
You are in a directory with 50 randomly named and sized images, and you want to know quickly the resolution of each file. Write a script called `mytechsource_getres' that takes no arguments and uses itstat to print the filename and resolution of each file in the current working directory in the following format:
[login to view URL]: 2048 x 1556 [login to view URL]: 2048 x 1556 [login to view URL]: 2048 x 1556
Please name the attachment for question 2 results: mytechsource_getres Then, describe how you would use this script to send a list of files matching the resolution 2048x1556 to a text file named `/tmp/2klist'.
Please name the attachment for this description: mytechsource_getres_usage
## Platform
Linux/Unix/BASH