[Gllug] Swapping two parts of a filename...

Mike Brodbelt mike at coruscant.demon.co.uk
Wed Jun 2 22:31:03 UTC 2004


On Wed, 2004-06-02 at 22:59, Dylan wrote:
> Hi All,
> 
> I have a bunch of mp3's with filenames like:
> 
> Track Name - Artist Name.mp3
> 
> which I'd really rather like as
> 
> Artist Name - Track Name.mp3
> 
> Is there an easy way to accomplish this? I also need to handle cases 
> where the track name or artist name contains a hyphen (in which case, 
> it would have a non-space character on each side.)

Something like:-

$ touch "Track Name - Artist Name.mp3"
$ ls
Track Name - Artist Name.mp3
$ /bin/ls -C1 | sed "s/\(.*\) - \(.*\).mp3/mv \"&\" \"\2 - \1.mp3\"/"|sh
$ ls
Artist Name - Track Name.mp3


Adjust your regex to fit...

HTH,

Mike.

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list