LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-04-2007, 01:39 PM   #1
schbond
Member
 
Registered: May 2002
Distribution: Gentoo
Posts: 54

Rep: Reputation: 15
mass mp3 directory renaming


I am trying to re-structure my mp3 directories. I currently have the following format:

artist-album-catalog-year

and I would like to rename the directories to:

catalog-artist-album-year

I was thinking of using a GUI mp3 tagging program, but most of my mp3's don't have a CATALOG tag. Also, I don't want to rename the files within the directories, just the directories themselves.

Any help would be appreciated.
 
Old 01-04-2007, 01:53 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Since I don't have these directories I haven't tried the following so do it at your own risk.

Go to parent directory then:

Code:
for DIRNAME in `ls -d *`
do NEWDIRNAME=`echo $DIRNAME |awk -F- '{print $3"-"$1"-"$2"-"$4}'` 
   mv $DIRNAME $NEWDIRNAME
done
The awk -F- says to use awk to split the name up and use the dash (-) as the delimiter. This makes your original name 4 fields in the order you see them. The print statment moves what was the 3rd field to the 1st field in the ouput. You have to reinsert the "-" litterally there.

Try it first with "echo" in place of "mv" to insure it gives you what you want for old name and new name.
 
Old 01-04-2007, 02:14 PM   #3
schbond
Member
 
Registered: May 2002
Distribution: Gentoo
Posts: 54

Original Poster
Rep: Reputation: 15
It took a little bit of tweaking, but awk was the tool I was looking for! Thanks, jlightner!
 
Old 01-04-2007, 02:17 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
No problem. You might want to post your final tweaked code that worked for people searching the forum later.
 
Old 01-05-2007, 11:18 AM   #5
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by schbond
I am trying to re-structure my mp3 directories. I currently have the following format:

artist-album-catalog-year

and I would like to rename the directories to:

catalog-artist-album-year

I was thinking of using a GUI mp3 tagging program, but most of my mp3's don't have a CATALOG tag. Also, I don't want to rename the files within the directories, just the directories themselves.

Any help would be appreciated.
there is too a kde apps for renaming ...

krename

Last edited by Xeratul; 01-05-2007 at 11:20 AM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Little utility for copying and renaming Mp3 files hansalfredche Linux - Software 3 12-24-2006 11:07 AM
Renaming group of files within one directory DIRdiver Linux - General 3 10-25-2006 09:57 AM
Renaming Directory Verbal Kint Linux - General 5 09-29-2006 12:09 AM
a question about renaming files in mass! zeltak Linux - Software 1 05-24-2006 06:12 AM
Renaming a directory. Is it possible? DC-4G Linux - Newbie 2 11-28-2001 01:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:12 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration