| Category: | Admin |
| Author/Contact Info | |
| Description: | First post in this section... takes database from amarok and replaces (\s'"\._) with - in the title and artist names to mv the old mp3 to title.'_'.artist.mp3 not the best description i know but make a backup of your music dir and test it :) let me know how it goes thanks. |
#!/usr/bin/perl use strict; use warnings; use DBI; my $dbh = DBI->connect( "dbi:SQLite:/home/simon/.kde/share/apps/amarok +/collection.db" ) or die "Cannot connect: ".$DBI::errstr."\n"; my $res = $dbh->selectall_arrayref("SELECT * FROM tags"); foreach (@$res) { my $artist = $dbh->selectrow_hashref("SELECT * FROM artist WHERE id= +'".$_->[5]."'"); $artist->{'name'} =~ s/[_ -\.]{1,}/-/g; $_->[8] =~ s/[_ -\.]{1,}/-/g; (my $full_title = $_->[8].'_'.$artist->{'name'}) =~ s/'"//g; change_name($_->[0],$full_title); } $dbh->disconnect(); exit(0); sub change_name { my ($url, $title) = @_; $url =~ s/^\./\/home/; $title = $1.$title if ($url =~ m/^(\/.*\/)/); $title .= lc($1) if ($url =~ m/(.{4})$/); `mv "$url" "$title"` if (!(-e $title) and -e $url); return(1); } |
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: small script to make mp3 filenames more command line friendly
by betterworld (Curate) on May 14, 2007 at 13:11 UTC |