Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: automatic file renaming?

__/ [ Kat ] on Sunday 14 May 2006 23:43 \__

> Hello everyone on this newsgroup,
> I'd like to know if it's possible to automatically rename a whole lot of
> files (namely mp3 files), is there a console command that would take
> care of it?
> 
> Here's an example of what I'm aiming at. I have lots of long file names
> like this one:
> 
> 01 - Artist Name - A Veeeeery Long Album Title - Song Title.mp3
> 
> I'd like to shorten them to:
> 
> 01 - Song Title.mp3
> 
> 
> Now don't tell me I have to rename 1429 mp3 files manually...
> Any help appreciated! Thanks.
 

You'll need to parse filenames, choose a new name for them and then rename
them. You might be better off asking in the Perl newsgroup. If you dump all
file to some playlist, e.g. ~/playlist.txt which contains newline-sparated
filenames, then do something like

,----[ Code ]
| #!/usr/bin/perl -w
| open(IFP,"/home/YOU/playlist.txt") or die
|      "could not open file: $!";
| $line=<IFP>;
| (undef,undef,$file)=split(/-/-$line);
| 
| # some Perly file moving operation
| 
| close(IFP);
`----

Perhaps this can serve as a rudimentary starting point.

Hope it helps,

Roy

-- 
Roy S. Schestowitz      |    "Oops. My brain just hit a bad sector"
http://Schestowitz.com  |  GNU is Not UNIX  ¦     PGP-Key: 0x74572E8E
 11:35am  up 17 days 18:32,  8 users,  load average: 0.59, 0.54, 0.52
      http://iuron.com - proposing a non-profit search engine

[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index