pastebin - collaborative debugging tool
kpaste.net RSS

Difference between
modified post 1e by Anonymous on Thu 6th Sep 2012 09:53
original post 42d8059b by Anonymous on Wed 5th Sep 2012 14:55
Download diff
Show old version | new version | both versions

    
11
#!/usr/bin/perl
22
33
use 5.14.0;
44
use strict;
55
use warnings;
66
#use File::Find qw(finddepth);
77
use File::Copy qw(move);
88
use File::Basename qw(basename dirname);
99
use File::Path qw(make_path);
1010
1111
#my $library = "/home/sir/Music/Songbird Music";
1212
my $library = "/home/sir/Music/Songbird Music";
1313
my (%files, @files, @dirs);
14+
my $flac_version = '1.2.1';
1415
1516
getdirs($library);
1617
1718
foreach my $dn (sort(@dirs)) {
1819
		chomp(my $ls = `ls "$dn"/*.flac 2> /dev/null | head -n 1`);
1920
		if (-f $ls) {
2021
	#		my @stat = stat($dn);
2122
	#		my $ino = $stat[1];
2223
	#		say "$dn has $ino";
2324
			undef %files;
2425
			undef @files;
2526
			getfiles($dn);
2627
			my $fc = scalar(@files);
2728
			if ($fc > 0) {
2829
				#replaygain($dn);
2930
				for (my $n = 0; $n < $fc; $n++) {
30-
					#say $files[$n];
3131
					my $fn = $files[$n];
32-
32+
					vendor($fn);
33-
					#rmtag($fn, 'rating');
33+
					rmtag($fn, 'rating');
34-
					#albumartist($fn, $fc);
34+
					albumartist($fn, $fc);
35-
					#track($fn);
35+
					track($fn);
36-
					#totaltracks($fn, $fc);
36+
					totaltracks($fn, $fc);
3737
	#				empty($fn);
3838
	#				duplicate($fn);
3939
					discnum($fn, $n, $fc);
4040
				}
4141
			}
4242
		}
4343
}
4444
# Make this subroutine and the whole script so that each file name is stored in a hash and that each member contains an anonymous hash with the tags (the alltags hash).
4545
# This means it won't have to look up the tags again for the albumartist subroutine.
4646
4747
sub gettags {
4848
	my $fn = quotemeta(shift);
4949
	my (%alltags, @mflac);
50-
	open(OUTPUT, '-|', qq{metaflac --no-utf8-convert --export-tags-to=- $fn}) || die "can't run metaflac: $!";
50+
	open(OUTPUT, '-|', qq{metaflac --no-utf8-convert --show-vendor-tag --export-tags-to=- $fn}) || die "can't run metaflac: $!";
5151
	chomp(@mflac = (<OUTPUT>));
5252
	foreach (@mflac) {
53-
		my @tag = split('=');
53+
		my (@tag, $tagname);
54-
		my $tagname = lc($tag[0]) or say $fn;
54+
		if (/^reference/) {
55+
			@tag = split(' ');
5758
		} else {
59+
			@tag = split('=');
5961
		}
62+

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at