I posted a question to Ubuntuforums.org yesterday about how one would go about authoring a script to sort several gigs of mp3's into two top level directories (better128) (less128) while preserving current parent directory structure.
I found out that in order to be able to read bitrate from mp3 files in bash you need a tool called mp3info
mp3info -r m -p %r file.mp3
will output the bitrate 128 on the resulting line
a friendly member showed me a sample script which i modified slightly with my own directory structures that would do almost exactly what i wanted
mkdir "$good" "$bad"
find "$music" -type f -name '*.mp3' -print0 | while read -d $'/0' file; do
if [ "$(mp3info -r m -p %r "$file")" -ls 129 ]; then
cp --parents "$file" "$bad"
cp --parents "$file" "$good"
when I run this script I get an error
read: 12: Illegal option -d
Now, I'm very new to scripting, so most of this is theory to me, but from what I see the find command is searching my music directory structure for files of type 'file' and named '.mp3' and then prints a null character at the end, which the while loop is looking for, once that happens all that data is scanned by mp3info and then sorted into directories based on the -lt statement
what i don't understand is why the delimiter -d command is giving an illegal output, or what the syntax error is in the loop statement. Can someone with more knowledge and expertise advise me if this is the correct way to accomplish what i want, and tell me where i'm going wrong in the syntax?
I appreciate it!