![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep Multiple Strings | durgaprasad | Shell Programming and Scripting | 10 | 06-26-2009 06:38 AM |
| grep strings of a certain length | angela.perez7 | Shell Programming and Scripting | 2 | 02-14-2009 03:39 PM |
| want to grep only strings in a file? | balan_mca | Shell Programming and Scripting | 5 | 11-03-2008 06:19 AM |
| number of lines returned from a grep command | cesarNZ | Shell Programming and Scripting | 4 | 10-09-2008 09:57 PM |
| Copying file names returned from a grep command into another directory | Kartheg | UNIX for Dummies Questions & Answers | 4 | 11-17-2005 12:34 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
downsizing of strings which are returned by grep
hey every1, i am a very new shell programmer. what i am trying to do is to rename a music file using its metadata(using mminfo)
the problem is, mminfo's output is very weird: Quote:
however, when i use Code:
artist=` mminfo ~/Desktop/It\'s\ Not\ My\ Time.mp3|grep artist` Quote:
How do i do that? I tried reading man page for cut, but cudnt understand much ![]() sorry for such a long post for a relatively simple problem ![]() |
|
||||
|
yes, i presume it will work. There are many ways to do this actually.
Code:
awk -F: '{print $2}'
print $1 will print "| artist" |
|
||||
|
this is what i actually set out to do:
plz have a look at the code below.. Something is rong with line 17
![]() Code:
#!/bin/bash
#Renames and organizes your music data.
#Provide the full path of your music folder as an argument.
#Renames music files according to its metadata in format "Artist - Title".
#Creates a folder with Artist name and stores file in it.
if [ -z $1 ];then #setting default directory
cd /home/abhigyan/Desktop/testing
else
cd $1
fi
for F in ./*
if [ -f $F ];then
artist=`mminfo $F|grep artist|awk -F: '{print $2}'` #getting metadata
chkartist=$?
title=`mminfo $F|grep title|awk -F: '{print $2}'`
chktitle=$?
if [ $chkartist -eq 0 || $chktitle -eq 0 ];then
filename="$artist - $title"
mv $F $filename
if [ -d $artist ];then #moving file to the artist folder
mv $filename ./$artist
else
mkdir $artist
mv $filename ./$artist
fi
else
echo -e "Skipping b/c insufficient metadata: $F \n"
fi
fi
done
Quote:
Last edited by abhigyan91; 07-20-2009 at 03:14 AM.. Reason: i added what the shell returns on executing the script;also bold changes in script |
![]() |
| Bookmarks |
| Tags |
| cut, grep |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|