LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 06-20-2004, 01:34 AM   #1
Shr00mBoXx
Member
 
Registered: Dec 2003
Distribution: Slackware 9.1
Posts: 63

Rep: Reputation: 15
Renaming multiple files with the same format


Ok, I know this is not default to slackware, but you all are my friends so I ask you.... I am restocking up my music collection on my computer... well the way I like songs formats are as follows
(Case sensative)
Group - Title Of Song.mp3

not that hard... I may switch over to

Track (00) - Group - Title Of Song.mp3

not Title of Song.. the "o" in of needs ot be caps too... but anyway I am downloading some things off torrent and get a CD with songs like the following

08-3_doors_down-dangerous_game-rns.mp3
09-3_doors_down-changes-rns.mp3
10-3_doors_down-going_down_in_flames-rns.mp3
11-3_doors_down-sarah_yellin-rns.mp3
12-3_doors_down-this_time-rns.mp3

is there an if statement I can run to turn that into....

08 - 3 Doors Down - Dangerous Game.mp3

thanks in advance

I am to lazy to cp song newformat

to lazy
 
Old 06-20-2004, 05:10 AM   #2
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
Code:
for i in *.mp3; do echo mv "$i" "$(echo $i | sed s/-rns// | sed s/-/\ -\ /g | sed s/_/\ /g)"; done
If this seems OK then remove the first 'echo' and let it run "for real"

Can't help you about the Caps though...
 
Old 06-20-2004, 05:27 AM   #3
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,535

Rep: Reputation: 116Reputation: 116
Usage : Take the mp3 directory as argument
Code:
#!/bin/sh

if [ -z $1 ]; then
	echo "This script take a mp3 directory as argument"
	exit
fi

cd $1
list=$(ls *.mp3)

ucfirst()
{
	char=$(echo $1 | cut -c 1 | tr a-z A-Z)
	str=$(echo $1 | sed 's/^.//')
	string="$char$str"
}

for mp3 in "$list"; do
	number=$(echo $mp3 | cut -d'-' -f 1)
	artist=$(echo $mp3 | cut -d'-' -f 2 | sed 's/_/\ /g')
        song=$(echo $mp3 | cut -d'-' -f 3 | sed 's/_/\ /g')

	name_final="$number -"
	
	for word in $artist; do
		ucfirst $word
		name_final="$name_final $string"
	done
	
	name_final="$name_final -"

	for word in $song; do
		ucfirst $word
		name_final="$name_final $string"
	done

	name_final="$name_final.mp3"

	if [ -f "$mp3" ]; then
		mv $mp3 $name_final
	fi
done

Last edited by keefaz; 06-20-2004 at 06:46 AM.
 
Old 06-20-2004, 05:58 AM   #4
Tuttle
Senior Member
 
Registered: Jul 2003
Location: Wellington, NZ
Distribution: mainly slackware
Posts: 1,289

Rep: Reputation: 52
mental code keef!
 
Old 06-20-2004, 06:19 AM   #5
mrpdaemon
Member
 
Registered: Jun 2003
Distribution: Slackware 9.1
Posts: 41

Rep: Reputation: 15
EasyTag would do the trick well too.
 
Old 06-20-2004, 06:47 AM   #6
keefaz
Senior Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 4,535

Rep: Reputation: 116Reputation: 116
Quote:
mental code keef!
...but it works Maybe in Perl it will be lighter

Last edited by keefaz; 06-20-2004 at 07:14 AM.
 
Old 06-20-2004, 06:51 AM   #7
Tuttle
Senior Member
 
Registered: Jul 2003
Location: Wellington, NZ
Distribution: mainly slackware
Posts: 1,289

Rep: Reputation: 52
[QUOTE]Originally posted by keefaz
Quote:
mental code keef![/code] ...but it works Maybe in Perl it will be lighter
By "mental" I mean "Beyond me!" with a touch of "Lost @~]" rather than "I'd have done it like this - blablabla"!
 
Old 06-20-2004, 07:22 PM   #8
Shr00mBoXx
Member
 
Registered: Dec 2003
Distribution: Slackware 9.1
Posts: 63

Original Poster
Rep: Reputation: 15
Thank you all very much for your help... easytag seemed to do the job :-P
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
renaming multiple files linuxhippy Slackware 10 01-21-2011 01:53 AM
renaming multiple files in general kkatebian Linux - General 5 11-06-2005 11:05 AM
Renaming Multiple Files with a "." on the end of the filename dbowles Programming 1 05-09-2005 04:28 PM
Need help with shell script - renaming multiple files NiallC Linux - Newbie 25 07-04-2004 10:45 AM
Solution: renaming multiple files with spaces HawkeyeCoug Linux - Newbie 0 03-26-2004 10:57 AM


All times are GMT -5. The time now is 11:19 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