Created
December 31, 2016 21:32
-
-
Save oprietop/61598779f11341c0ed6dd84b614b1c6d to your computer and use it in GitHub Desktop.
Getting some help to tag a bunch of single flac+cue files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use Cwd; | |
use File::Find; | |
my $dir = $ARGV[0] || $ENV{PWD}; | |
chdir($dir); | |
my $dir= getcwd(); | |
print "$dir\n"; | |
sub process_file { | |
if ( -f $_) { | |
my $file = $File::Find::name; | |
my ($old, $new, $cd); | |
if (($new, $old) = $file =~ m@/([^/]+)/[^/]+(\[[^\]]+\]) FLAC\.cue$@) { | |
} elsif (($new, $old, $cd) = $file =~ m@/([^/]+)/CD \d+/[^/]+(\[[^\]]+\]) (CD\d+) FLAC\.cue$@) { | |
$new = "$new, $cd"; | |
} | |
next unless $new; | |
print "\ncue: '$file'\nold: '$old' new: '$new'\n"; | |
my $slurp = do { local( @ARGV, $/ ) = $file; <> }; | |
$slurp =~ s/\Q$old\E/[$new]/; | |
print $slurp; | |
open(my $fh, '>', "$File::Find::dir/new.cue") or die; | |
print $fh $slurp; | |
close $fh; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment