UNIX: changing multiple file names without hassel?

wizzz

Senior member
Jul 20, 2000
267
0
0
In UNIX systems, is there a tool or utility to change multiple file names with a few commands?

For example, suppose I have 200 MP3 files.
And all the file names are "MusicianName-Album-SongName-TrackNumber.mp3"

How would I cut off the MusicianName field of each file name? (for all 200 files)
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Write a script. You could probably do it in perl quickly.

Which Unix do you have that many mp3s on?! I wasnt aware Aix had sound :)P) and didnt think Solaris' sound was all that worthwhile. HP-UX have decent sound? (I think thats all the Unixes out there really... cant remember for sure though)
 

bizmark

Banned
Feb 4, 2002
2,311
0
0
Originally posted by: n0cmonkey
Write a script. You could probably do it in perl quickly.

Which Unix do you have that many mp3s on?! I wasnt aware Aix had sound :)P) and didnt think Solaris' sound was all that worthwhile. HP-UX have decent sound? (I think thats all the Unixes out there really... cant remember for sure though)

wouldn't the answer apply to Linux as well as UNIX proper?
 

Bremen

Senior member
Mar 22, 2001
658
0
0
n0c is just using his nonexistent humor to point out the original posters mistatements
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
use rename. i dont know if rename is a gnu tool and/or how common it is outside of linux, but its immensly useful for this type of thing. it uses perl regular expressions. for example:

something like this:

rename 's/(.*)-(.*)-(.*)-([0-9]*)\.mp3/\\2-\\3-\\4.mp3/' *3

that might be a bit off, do a test run first! ;)
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Sweet! I was going to do a shell script with sed, but rename is clearly better suited for the job. Nice, BBWF.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
I was going to do a shell script with sed, but rename is clearly better suited for the job. Nice, BBWF.

<oldmanvoice>yeah back in my early linux days (*cough*last spring*cough*) i didnt know wtf i was gonna do about renaming mp3's, and i decided i'd have to either learn perl or write a horrificly ugly/messy/buggy bash/sed script for every specific use.</oldmanvoice>

then i found rename! (larry wall, you rock :D)
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Yeah, I'll have to grow the balls to read up on regular expressions again. I wrote a script or two using them to track ports in BSD a couple months back, and they worked well. But lately, every time I have a problem to solve, I look at all those special characters, and my eyes glaze over.

Still, sed is the way to go for editing .m3u's, at least.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Bremen
n0c is just using his nonexistent humor to point out the original posters mistatements

rolleye.gif
 

Need4Speed

Diamond Member
Dec 27, 1999
5,383
0
0
Originally posted by: Bremen
n0c is just using his nonexistent humor to point out the original posters mistatements

I wouldn't have believed it, if I hadn't seen it with my own two eyes :p