The objectives of this lab experiment are to make you :
bash scriptingcmd scriptingThe two articles on Scripting by Prabhaker Mateti in the References are Required Reading.
This Lab is about scripting. It uses MP3 files as a domain where scripting can be usefully deployed. It is not crucial that you understand the internal structure of MP3 files. It is sufficient to know that the ID3 tags are embedded with the MP3 files. For further details on MP3 files, read the Wiki article mentioned in the References.
You will be creating a bunch of MP3 files in a
TESTMP3 directory. These are "artificially" created, not playable
"music" files. But the tool we use to manipulate, namely id3tool
in Linux and in Windows, does not touch the musical content.
The tool manipulates only the ID3V1 tags. Invoking id3tool
with no arguments displays its usage. Invoking id3tool with the
name of an MP3 file as its only argument displays its ID3V1 tags. See the
References for download details of the tool.
For our experimental purpose, this
TESTMP3 will contain about a 100 files. These files do have Album, Artist, and Year tags.
They may or may not have a track number or title tags. Assume that these tags do not have
white spaces. You will be creating subdirectories based on the Album name and
the Year as in Album-Year, and moving into each Album directory the
files of that album. You will then be renaming each file based on the
track number, album, and artist as in nn-Album-Artist.mp3.
Here is an example of how a dummy MP3 file (name = first argument) whose tags are Album (second argument), Artist (third argument), Year (fourth argument) can be created in the current working directory. Feel free to be more creative than this! You may earn bonus points!
createOneDummyMP3File()
{
echo > $1.mp3
id3tool $1.mp3 -a $2 -r $3 -y $4
}
Obviously, in creating 100 dummy files, you need to come up with different file
names, album names, etc. Some of them should also have the track
number tag.Exercise: Discover what the following do:
id3tool fileName.mp3 | grep Album | sed 's/^Album:[ \t]*//;s/ *$//'id3tool fileName.mp3 | sed "/^Artist/d;/^$/d;s/[ \t]*$//"All work is expected, but not required, to be carried out in the Operating Systems and Internet Security (OSIS) Lab, 429 Russ. But, you are welcome to work wherever. Note that use of both Linux and Windows and other software, that may not always be installed in other facilities, may be needed.
In Linux
id3tool program binary into your
home directory. Setup id3tool as an alias to this.createTestMP3Files() that
creates a subdirectory named TESTMP3 in the current working
directory, and populates it with about a 100 dummy MP3 files as described in
the Background.sortMP3Files() that "sorts"
and moves MP3 files located in the source directory SOURCE given as the
first argument into the destination directory DEST given as the second
argument.nn-Album-Artist.mp3. If an MP3 file has
no track number tag, use your judgment to give it a default tag number.taggingMP3.sh. It should (i) create an empty
subdirectory named RESULTSMP3 in the current working directory,
(ii) invoke createTestMP3Files, (iii)
long-list the directory TESTMP3, (iv) invoke
sortMP3Files TESTMP3 RESULTSMP3, and (v)
recursively long-list the directories TESTMP3 and RESULTSMP3.In Windows
taggingMP3.bat equivalent to the
above in the cmd syntax. Use standard commands that come with
Windows cmd. You must make use of procedures, perhaps one for each of the
tasks above. Note the number <n> of this Lab from the course home page and use L<n> as the
first argument to turnin. Read the Grading Sheet to determine
what files must be submitted.
For 20 max bonus points, show us the evidence that you used your script on your collection of real MP3 files.
/home/ceg233/ceg23300/bin/id3tool.
A Windows exe of id3tool is also located at:
/home/ceg233/ceg23300/bin/id3tool.exe Recommended Tool.| . |
| Copyright © 2009 Prabhaker Mateti | last edited: June 24, 2009 |