We want to make a playlist with our favorite artists.
This is a problem that needs string matching.
String is a sequence of alphanumerical characters.
So, let's consider the problem:
One of our favorite artists is Celine Dion.
But there are some problems in our folders:
The name of Celine Dion is correct, but in french, i.e. it's Céline Dion. Also, not all folders have just the artist's name. E.g there is a folder Celine Dion - Titanic.
So, let's go back to previous lessons.
Remember the * sign?
It means whatever characters. So if I write *l* means, all the strings that contain the letter l.
In the previous lessons we were searching for mp3's like that, *.mp3. It means whatever string ends with the characters .mp3 .
So, we are going to use that.
E.g if we are searching for folders of Celine Dion we are going to search only the characters that are common. Remember! Neither use so many nor so little:
We used *line*Dion* : this means, whatever characters, then 'line' then whatever characters and then Dion. We could use *Dion* or *C*line*Dion, but it's up to you what you think is right for your case.
So that's the previous code:
for music in */*/*.mp3; do
playlist+=$music;
done; audacious "$playilist" -E
Now we want to make a permanent playlist with our favourite artists!
Make sure that the playlist is empty:
audacious &
choose playlist, delete playlist (it closes the playlist, if you want
the playlist export it before deleting)
run that command:
for music in *line*Dion*/*/*.wma; do
audacious -e "$music" &
done
So after that you can run as many scripts as you want and add your favorite songs.
Then export the playlist so you can use it again.
Questions to consider until Saturday:
- Why have we used '&' after audacious -e "$music"? What does it means? try to open other programs with '&' at the end and without it!
- Why we put the audacious -e "$music" & in the for loop and didn't used a playlist variable like before? What script is better?
- Why music variable has a '$' in the for loop?
- Why have we put *.wma instead of *.mp3? Are you going to do the same?
- Why the -E became a -e? Check man audacious to find out!
Saturday same place :P
No comments:
Post a Comment