Register
It is currently Sat Aug 30, 2014 2:23 am

Directories being created with the wrong name


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sun Aug 12, 2012 9:49 pm   

Joined: Sun Aug 12, 2012 9:39 pm
Posts: 1
I'm writing a script to organize all my music files into folders according to their artist and album. I'm using id3tool to get the id3 information from the mp3s. When id3tool sends its output, there are two tabs before the artist/album. I'm using tr to get rid of the tabs.

So far, my code looks like this:
Code:
ARTIST=`id3tool "$CURRENT_FILE" | grep "Artist" | awk -F ":" '{print $2}' | tr -d '\011'`
if [ ! -d "$ARTIST" ]
                        then
                                mkdir "$ARTIST" #> /dev/null 2>&1
fi


The directory will be created, however the name will be something random like SCZZ9H~R. However, when I echo $ARTIST, the name is as it's expected to be.

I am at a loss as to why this is happening.


Top
 Profile  
 PostPosted: Sun Aug 12, 2012 11:19 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 535
hi,

awk is not a super `cut'ter, it is a Ā« pattern scanning and text processing languageĀ»!
so using grep, tr, or/and else is useless.
Code:
artist=$(awk -F':\t*' '/Artist/{print $2}' < <(id3tool "$file")

nb: uppercase variables are reserved to environmental variables by convention.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP