[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Simple music sorting script.

Posted on 2006-05-09
6
Medium Priority
?
292 Views
Last Modified: 2008-01-09
Hey, I was wondering if it would be possible to make a script that would half-automate the process of sorting out my hundreds of music files. Basically, I want to sort them out into folder, depending what their style is(i.e. soothing, thrilling, suspenseful, happy, etc.). Simply put, I want it to do this:

Play a random thirty seconds of the first music file in the folder, during which time I can press a key that will move it into a folder(when I press "s", it goes into the suspeneful folder). As soon as I press the key, it moves on to the next music file, playing another random thirty seconds from there, and again, I press the appropriate key to move it into the appropriate folder.

I would prefer the script be something that I can just use(i.e. an sh script), but if my requirements need another language, then the requirements should come first. For the music player, it can be whatever will work with mp3 files, I'm willing to download another(linux compatible of course).

Thank you for your time.
0
Comment
Question by:Icewolfx
6 Comments
 
LVL 11

Expert Comment

by:kblack05
ID: 16642725
What have you gotten so far? Do you have any scripting going and need help with it? Do you need a developer to do this for you?
0
 

Author Comment

by:Icewolfx
ID: 16642756
I have tried some basic scripts, but I have neither the expertise nor the time to dedicate to this. It would be great if the script was just made, otherwise, pointers to exactly the right functions will be accepted.
0
 
LVL 27

Accepted Solution

by:
Nopius earned 1920 total points
ID: 16645906
try something like this (not tested, but not dangerous :):

#!/bin/bash
selector () {
  echo Press number:
  echo 1 - soothing
  echo 2 - thrilling
  echo 3 - suspensful
  echo 4 - happy
  read -n 1 resoponse
  exit $response
}

map_to_dir () {
  case $1 in
    1)
        echo 'directory_for _soothing/'
        ;;
    2)
        echo 'directory_for _thrilling/'
        ;;
    3)
        echo 'directory_for _suspensful/'
        ;;
    4)
        echo 'directory_for _happy/'
        ;;
    *)
        echo 'unsorted_directory/'
        ;;
  esac
  exit $1
}

# Suppose all files are in current directory
for file in *.mp3
do
    mpg123 --gain 100 --skip 10 $file > /dev/null 2>&1 &
   # background Process Id
    bg_pid=$!
   # clear screen
   clear
   selector
   where_to_move=`map_to_dir $?`
   mv $file $where_to_move
   kill $bg_pid
done
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Assisted Solution

by:da99rmd
da99rmd earned 80 total points
ID: 16648495

Nice script but it had a few errors:
#!/bin/bash
selector () {
  echo Press number:
  echo 1 - soothing
  echo 2 - thrilling
  echo 3 - suspensful
  echo 4 - happy
  read -n 1 response
  return $response
}

map_to_dir () {
  case $1 in
    1)
        echo 'directory_for _soothing/'
        ;;
    2)
        echo 'directory_for _thrilling/'
        ;;
    3)
        echo 'directory_for _suspensful/'
        ;;
    4)
        echo 'directory_for _happy/'
        ;;
    *)
        echo 'unsorted_directory/'
        ;;
  esac
  return $1
}

# Suppose all files are in current directory
for file in *.mp3
do
    mpg123 --gain 100 --skip 10 $file > /dev/null 2>&1 &
   # background Process Id
    bg_pid=$!
   # clear screen
   clear
   selector
   where_to_move=`map_to_dir $?`
   mv $file $where_to_move
   kill $bg_pid
done

/R
0
 

Author Comment

by:Icewolfx
ID: 16651004
It might work, but the problem is that the music titles contains special characters and spaces, so that the script neither plays the file nor moves it into the appropriate directoy. An example of the filenames is:

Zone\ Of\ The\ Enders\ -\ Konami\ -\ Flowing\ Destiny\ (Resolution)\ (0-45).mp3

If anyone could tell me how to modify the script to make it work properly with those names, that would be fantastic. Thanks.
0
 

Author Comment

by:Icewolfx
ID: 16651081
Cancel that, I figured it out. For those interested, I simply put $file in double quotes(i.e. mv "$file" $where_to_move).

It looks like the script is working out fine. Thank you so much :).
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Integration Management Part 2
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question