LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-23-2003, 02:18 AM   #1
d003
LQ Newbie
 
Registered: Jul 2003
Posts: 2

Rep: Reputation: 0
Question linux shell - extract filename from and song info from text database


Hello!

I have filename that contains following mp3 song information:

4342;Cher;Believe;Y;0;000
4343;Jovanotti;Bella;Y;0;001
4344;Eric Clapton;Change the World;Y;0;002
...
...
...
(ID;Artist;Song;Directory1;Directory2;filename)

The song files are located under different directories, for example: /Y/0/filename.mp3, or /X/2/filename.mp3

I need to write a script (shell) that would rename the files to the real artist and song names and copy them to single location, basically after extracting data from the upper file I need to get command similar to:

cp Y/0/002.mp3 Cher - Believe.mp3

or

cp X/4/009.mp3 Aerosmith - Amazing.mp3

I hope I was clear enough of my needs and I really need your help on this, since I've been trying for two days now, without any success.

Thanks!!
 
Old 07-23-2003, 04:06 AM   #2
d003
LQ Newbie
 
Registered: Jul 2003
Posts: 2

Original Poster
Rep: Reputation: 0
Hi!

Allready found the solution, if anyone need something similar here is it:

awk 'BEGIN {FS=";"} { printf("cp %s/%s/%s.mp3 \"new_directory/%s - %s.mp3\"\n", $4, $5, $6, $2, $3) }' file_list | sh

Asuming that the new files will go to new_directory and filelist is in file_list file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restoring *.sql database from Linux Fedora's shell marciano Linux - Newbie 1 10-19-2005 06:05 PM
Need to extract info out of a binary file synapse Programming 6 09-27-2005 04:55 AM
Extract text from a html file gsphanikumar6 Linux - Newbie 2 08-20-2004 01:11 PM
extract text portions from html files linuxfond Programming 3 04-28-2004 11:00 AM
"how do I extract a number from a text file using shell command?" sdandeker Linux - Networking 3 02-12-2004 08:54 AM


All times are GMT -5. The time now is 07:11 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration