Tip #10: Zipping and unzipping many files in a folderWhenever you need to upload many mp3 files its painful zipping each one of them. Usually I put all of them in a single folder and use a custom script to zip all the mp3 files in that folder.
The script I use is as follows:-
QUOTE
for FILE in *.mp3; do
OUTFILE="${FILE%%.mp3}.zip"
echo $OUTFILE, "$FILE"
zip "$OUTFILE" "$FILE"
done
exit 0
If you want to use the same script, just copy the code to a file (say, makezip.sh), make it executable (using
chmod +x makezip.sh) and copy it to your /usr/bin folder. From then on it can be run by you in any folder you want.
Sometimes I have the reverse requirement. I downloaded say 10 files and its boring to unzip all. So I use the reverse script makeunzip as follows:-
QUOTE
for FILE in *.zip ; do
unzip "$FILE"
done
exit 0
Linux users shall know that zip is a good ethical format to use. Unfortunately, many users upload rar files (which is a non-free standard). So to unrar I use the following script:-
QUOTE
for FILE in *.rar ; do
unrar x "$FILE"
done
exit 0
For ethical reasons I don't rar. For the unaware, I am reproducing
a post on another website on why I one should not use rar.
QUOTE
Quite a large amount of data has been made available on peer-to-peer networks within the last few years. A lot of people see this a sign of a broader change in relationship between content authors and recipients. Many talk about revolution. Some of that data on these networks, specifically complete music albums, full discographies and movie subtitles, is compressed using the RAR archiver, most often with no real reason. In this document, I want to try to explain why I believe that this method should be avoided in order to make the digital revolution happen faster, less problematically and in a just and non-discriminatory fashion.
Before we make our point, let us tell you that it is really useless to compress audio data which is probably encoded into MP3 or Ogg Vorbis and thus already heavily compressed, leaving very little if any room for additional shrinking using the RAR archiver. For example, full discography of the legendary UK Subs occupies 1037 megabytes of hard disk space as a directory of MP3 files or 1025 megabytes as a single compressed archvive file. The difference is negligible both in terms of disk storage space and connection bandwidth. Off course, you still may want to put all the audio files into one large file, in order to facilitate sharing of the data over a peer-to-peer network. For this purpose, there is available a utility called Tar (see google), which is way faster, smaller and simpler than the RAR archiver. It doesn't perform any compression, just sticks the files together.
Why you should care? Does it matter if you waste only a few seconds of CPU time for useless compression? Maybe it doesn't, but there's another issue; a much more important one. It's that the RAR archives, or at least the vast majority of them, cannot be decompressed with free software. Free software is such software whose license enables it to be run for any purpose, to be studied and analyzed, modified and redistributed with or without modifications and with or without a distribution fee. The growing social movement which has gradually developed around this kind of software within the past twenty years and which has brought to the public such works as the GNU/Linux and BSD operating systems, the Apache web server, the Mozilla Firefox web browser or the OpenOffice.org suite, is generally believed to be an indispensable part of the digital media revolution. Many members of that movement believe that in order to take their case seriously, they have to refuse to use any non-free software.
Unfortunately, there is no free software RAR decompressor that could handle the vast majority of RAR archives currently shared on the network. The official RAR decompressor is freeware and its source code is available, but it still doesn't make it free software at all, as the license still heavily restricts the users' rights and freedoms. There is another RAR decompressor which is available under the free software movement's flagship GPL license. Unfortunately again, that program can only handle archives generated by RAR 2.x and as far as RAR 3.x archives - today de facto standard on peer-to-peer networks - are concerned, only their contents can be listed but no actual data can be extracted. This may never change, since RAR 3.x includes patented algorhitms and it would require a pretty smart programmer to reverse-engineer the format without violating the patents.
In conlusion, it's not possible to decompress modern RAR archives with free software. Therefore, please don't publish or share such archives, since it is discriminatory against members of the free software movement. This movement is part of the same revolution as the peer-to-peer networks are, so we believe that the two communities should cooperate and tolerate each other's ideals. If you need to stick many short files together, use Tar, and if you really need to compress them (or if you don't like Tar for some reason), please use the traditional Zip format which is easily readble by free software decompressors as well. You will contribute to development of better society. Thank you very much.