Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 04-05-2006, 12:21 PM   #1
Registered: Feb 2005
Location: Ontario, Canada
Distribution: Gentoo, Slackware
Posts: 345

Rep: Reputation: 30
Script to Rename Many Files

I have inherited a massive collection of mp3s from a friend.
Unfortunately it's very disorganized and they're all in one directory.

I'm wondering if there is some sort of shell scripting solution that can solve my file name woes.

Imagine that there were a band named "Linux Questions" and I have a bunch of their mp3s mixed into a directory with thousands of other mp3s.
Unfortunately the file names vary from containing "LINUX QUESTIONS", "linuxquestions", "Linux-Questions", "linux_questions", etc...

I would like to write a script that would find all of these file names, and rename them so they all use the consistent variant of "Linux Questions - SongName".

Hopefully this is clear.
Can anyone point me in the right direction to do this?
Old 04-05-2006, 01:13 PM   #2
Senior Member
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
the easiest way would be if the id3 tags are accurate, you could use just about anything (lang) to do it.. however if they are not my vote would be with perl, and it has several id3 tag libs available so that you could fix the id3s once you are done..
Old 04-05-2006, 01:16 PM   #3
LQ Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 272Reputation: 272Reputation: 272
I've never used any of these, but here's a couple of links to some scripts someone else has already written...
Old 04-05-2006, 01:45 PM   #4
Registered: Feb 2005
Location: Ontario, Canada
Distribution: Gentoo, Slackware
Posts: 345

Original Poster
Rep: Reputation: 30
Unfortunately the ID3 tags seem to be worse than the file names themselves, but I'll still give the linked to scripts a try when I get home.

I've been giving this some more thought today.
What if I could write a regular expression that matches most variations on the artist's name. Is there any type of CLI tool that can match regular expressions and then replace only the part of the file name that matches the expression?


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch Script to rename files... jamie_barrow Linux - Newbie 16 06-14-2009 01:26 PM
script to rename muliple files cranium2004 Programming 3 02-21-2006 10:59 PM
rename script all files in dir Longinus Linux - Newbie 8 08-02-2004 12:24 AM
Need script to rename files joe_stevensen Programming 5 12-05-2003 06:12 PM
Got a script to rename a batch of files? jamie_barrow Linux - General 1 08-08-2003 06:52 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:16 AM.

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