1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#!/usr/bin/perl
#
# Written to suppliment crip with a Ogg Vorbis tag editor.
#
# Put preferred editor here
$editor = "vim";
$file = $ARGV[0];
unless (-e "$file") {
die "File \"$file\" does not exist.\n";
}
unless ($file =~ m/\.ogg$/) {
die "File \"$file\" does not have the .ogg extension.\n";
}
if (-e "$file.tag.tmp") {
die "WTF is \"$file.tag.tmp\" already doing in /tmp ?!\n";
}
# Escape certain characters from $file
# code taken directly from crip actually (crip does the same
# sort of thing 3 different times in its code)
# (don't ask me why it worked above but doesn't work below without escapes)
$file =~ s/\(/\\(/g; $file =~ s/\)/\\)/g;
$file =~ s/'/\\'/g; $file =~ s/`/\\`/g;
$file =~ s/\"/\\\"/g; $file =~ s/ /\\ /g;
system "vorbiscomment -l $file > /tmp/$file.tag.tmp";
system "$editor /tmp/$file.tag.tmp";
print "Writing new tag info...\n";
system "vorbiscomment -w -c /tmp/$file.tag.tmp $file";
print "Done.\n";
print "Deleting temporary file /tmp/$file.tag.tmp\n";
system "rm /tmp/$file.tag.tmp";
print "\nTag info now reads:\n";
system "vorbiscomment -l $file";
print "\n";
|