Jump to content

Where do I go after learning dos shell?


tylersands

Recommended Posts

I just got done learning DOS Shell script. My goal is to learn and master java, but I started dos because it seemed WAY simpler, and I heard that it is easier learning a second coding language than a first. What is the next step? Where do I go from here? Any advice would be much appreciated.

Link to comment
Share on other sites

DOS Shell is not a Coding Language, its a scripting language.

Learn BASH, similar to DOS but for Linux and way way more flexible/powerful

The first Coding Language anyone should learn is C, because most other language use the same syntax, Java use C like syntax.

When you grasp C/C++, all other language will open up easily. Java is the most difficult one to learn and most of what you will learn wont apply to other language except C# maybe, while its easy to get started, once your application get more complex you will have to learn tons of concept about memory management, override, interfaces... but it does open the mobile device APP market so its a worthy language to learn but don't get fooled by how easy it is to get started. Java book are HUGE and you likely need to grasp at least 50% of it before you can produce anything useful, that being said, 75% of the APP on the APP market are written by lazy monkey who just put a webview (instance of web browser) in their APP then do the rest of the coding in HTML5/Javascript... So learn those 2 too....

Edited by madhak
Link to comment
Share on other sites

Tomayto tomahto. But I second the suggestion of learning bash.

The thing about bash that kicks DOS batchfiles in the shins if not higher up the leg area is functions! The one thing to remember about bash is that it actually contains very, very little internal functionality. The main focus of the shell lies in the proper sequencing of stuff.

Here's something I wrote some scripts for that you might find a useful exercise to perform yourself:

1. I've found that mp3 tracks with a constant bitrate of 192 kbit are the most compatible with all devices, but when I download a track it rarely is at that rate. Write a script that uses the mp3info program to discover the bitrate of an mp3 file and ONLY when it's not 192 cbr use the lame program to decode the mp3 to wav and again to re-encode the wav to mp3. 192 vbr isn't good enough and also must be recoded.

2. Those files aren't always mp3. Some are in flac (flac), m4a or wma (mplayer), ogg (ogg123) or wav. Make the script support that aswell. The bit after an extension in brackets is the name of the program that can decode files of that type to wav. Feel free to use other programs if you're more familiar with them. Make sure that when you re-encode a file you either remove or rename the original and the intermediary .wav file otherwise repeat runs will keep finding them and redoing the work.

3. Make your script traverse a directory tree, such that if the present working directory is /tmp/blah it will find and go to work on /tmp/blah/first.mp3 and also /tmp/blah/some/path/to/second.mp3 but not /tmp/third.mp3 nor /tmp/other/fourth.mp3

4. My MP3 collection is structured in a very specific way:

[first letter of the bandname]/[bandname]/[albumname]/[2-digit track number]. [trackname].mp3

So if I were to look for the song "There Is No I In Fuck You" by "Walls Of Jericho", I'd find it here:

W/Walls Of Jericho/All Hail The Dead/02. There Is No I In Fuck You.mp3

Using the mp3info program you can ID3 tag your MP3s. Given the file structure above, starting from any directory, traverse the directory down and place a tag on any encountered .mp3 file assuming the structure mentioned above. Ignore all non-mp3 files. You should be able to include in the tag all the elements except of course the first letter of the bandname which is irrelevant and all elements which can be set in a tag but you don't know given the directory structure must be cleared.

5. When I download files, they tend to start out as a bunch of files in a folder named something stupid like:

Some_Band-Awesome_Album

And each file ends up being named something like this:

Some_Band-Awesome_Album-04-Cool_Track-RiPpEd_By_W4NK3R.mP3

Some_Band-Awesome_Album-05-Boring_Track-RiPpEd_By_W4NK3R.mP3

Create a script that will replace the first occurrence of a specific section of a filename with something else which is potentially nothing (i.e. remove that bit) and if that something else is not nothing allow me to provide an additional parameter to indicate I don't want this to happen only the first time, but on each occurrence of the sequence in the filename.

With my current script on the files mentioned above that looks like this:

replace.sh Some_Band-Awesome_Album-

replace.sh -RiPpEd_By_W4NK3R

replace.sh mP3 mp3

replace.sh - .\

replace.sh _ \ g

In those commands, each time you see a \ it's followed by a space and in that last one by 2 spaces. End result is:

04. Cool Track.mp3

05. Boring Track.mp3

6. You may have noticed that in the directory structure, all the words in a name start with a capital letter and the rest is lower case. Write a script that can do this for all files in a directory, not juse the MP3s. Note that some files have special characters in their names like this:

03. Some Track (Bonus).mp3

04. Other Track [Featuring Somebody].mp3

Be careful working with these but know that basically the first letter of a name and every letter following a space, a bracket or a brace should be capitalized. You can use the 'tr' command to go from upper to lower case and back again.

I managed to put all these functions in 3 scripts:

capitalize.sh (163 bytes)
recode.sh (2318 bytes)
replace.sh (91 bytes)

I'm mentioning the size so you know if your version is more than double that you're probably trying too hard.

Enjoy and feel free to ask for help. It's what we're (also) here for.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...