aubuti,

Thanks so much for the helpful suggestion.  I ran the command with the
"quotes" around the path to my music as you suggested, and it worked!

I have also used Foobar 2000 to add replaygain tags and it worked well,
too, but the apply_replaygain.pl script allows me to do the analysis and
tagging on my NAS, without tying up my PC.

If anyone else wants to run apply_replaygain.pl on a FLAC library on
their Thecus NAS, try comparing and contrasting my edited script below
with the script available from 
(http://projects.robinbowes.com/apply_replaygain) to see how to specify
the path of perl and the metaflac file. My perl was installed by
downloading the perl module for the Thecus N5200 (this module is needed
anyway to run Slimserver/squeezecenter on the Thecus N5200) and
installing it via the Module Management function.  The metaflac file
comes from the linux package from
http://flac.sourceforge.net/download.html and I installed it to
raid/data/ on the N5200 using SSH Secure Shell.  I also installed the
apply_replaygain.pl download to using raid/data using SSH Secure Shell.
Make sure apply_replaygain.pl and metaflac are executable via
permissions.

To run the program, I navigate to the directory contaning
apply_replaygain.pl and used the command ./apply_replaygain.pl --info
"/raid/data/Music Server/FLACs/1473B-FLAC/David Bowie"

Here is what it looked like in SSH Secure Shell:

[EMAIL PROTECTED]:/raid/data/apply_replaygain-0.2# ./apply_replaygain.pl
--info "/raid/data/Music Server/FLACs/1473B-FLAC/David Bowie"
Checking directory: /raid/data/Music Server/FLACs/1473B-FLAC/David
Bowie
Checking directory: /raid/data/Music Server/FLACs/1473B-FLAC/David
Bowie/Changesbowie
Processing dir: /raid/data/Music Server/FLACs/1473B-FLAC/David
Bowie/Changesbowie
Checking directory: /raid/data/Music Server/FLACs/1473B-FLAC/David
Bowie/Space Oddity
Processing dir: /raid/data/Music Server/FLACs/1473B-FLAC/David
Bowie/Space Oddity
[EMAIL PROTECTED]:/raid/data/apply_replaygain-0.2#

The "./" at the beginning are needed at the beginning of the command. 
As aubuti so helpfully noted, make sure to use quotes around paths
containing spaces.


Here is my edited script:

#!/raid0/data/module/PERL/perl/bin/perl -w
#
# $Id: apply_replaygain.pl 4 2007-12-31 13:55:39Z robin $
#
# Applies replaygain tags to all .flac files found within the
# specified directory tree.
#
# Album gain is also calculated for all files within each directory.
#
# Usage:
#
#  apply_replaygain.pl [options] [directory]
#
# Options:
#  --processall      Default behaviour is if all files in the
directory
#                    have ReplayGain information (specifically, the
#                    REPLAY_ALBUM_GAIN tag) then the directory is
skipped.
#                    This option recalculates ReplayGain information
#                    for all directories.
#   --info           Output information (directories processed, etc.)
#   --debug          Output debugging information
#
#  directory is the directory to scan for flac files. If omitted, the
#  current directory is processed.
#
# Possible customisations:
#  location of perl in line 1
#  location of metaflac program (see $metaflac below)
#  metaflac arguments (see $metaflacargs below)
#
# Robin Bowes ([EMAIL PROTECTED]), 2004

use strict;
use FindBin;
use lib "$FindBin::Bin/lib";
use Audio::FLAC::Header;
use Getopt::Long;

#------------------- Begin User-changeable options
--------------------

# Assume metaflac is in the path.
# Change this line if it is not. 
our $metaflaccmd = "/raid0/data/flac-1.2.1-linux-i386/bin/metaflac";

# Depending on your application, you may not require
--preserve-modtime
our @flacargs = qw ( --preserve-modtime --add-replay-gain );

#-------------------- End User-changeable options
---------------------

#use vars qw (
#  $::Options{processall}
#  $d_info
#  $d_debug
#);

our %Options;

GetOptions( \%Options,
"processall!",
"info!",
"debug!",
);

# Set defaults
#$::Options{processall} = 0;
#$d_info     = 0;
#$d_debug    = 0;

showusage() unless ( scalar @ARGV <= 1 );

# Use current directory if no dir specified on command-line
@ARGV = ('.') unless @ARGV;

process_dirs(@ARGV);

1;
## End of main program

sub process_dirs {
my @dirlist = @_;
foreach my $dir (@dirlist) {
$::Options{info} && msg("Checking directory: $dir\n");

# get all directory entries
opendir( DIR, $dir ) or die "Couldn't open directory $dir\n";
my @direntries = readdir(DIR)
or die "Couldn't read directory entries for directory
$dir\n";
closedir(DIR);

# get all target files within the present directory
my @target_files = map { $_->[1] }    # extract pathnames
map { [ $_, "$dir/$_" ] }           # form (name, path)
grep { /\.flac$/ }                  # just flac files
sort @direntries;

# get all subdirs of the present directory
my @subdirs = map { $_->[1] }         # extract pathnames
grep { -d $_->[1] }                 # only directories
map { [ $_, "$dir/$_" ] }           # form (name, path)
grep { !/^\.\.?$/ }                 # not . or ..
sort @direntries;

$::Options{debug} && msg("processall:  
$::Options{processall}\n");

# If any files exist to be processed
if (@target_files) {

# Don't bother checking the target files if
# processall options specified
my $processdir = 0;
if ( !$::Options{processall} ) {

# Check all files for ReplayGain tags
# Process the whole directory is any files found
without
# ReplayGain.
foreach my $flacfile (@target_files) {

$::Options{debug} && msg("processing file:  
$flacfile\n");

my $flac = Audio::FLAC::Header->new($flacfile);

# Check for existence of REPLAYGAIN tag
my $RPGTag = $flac->tags("REPLAYGAIN_ALBUM_GAIN");
$processdir = 1 unless defined $RPGTag;

$::Options{debug} && msg("RPGTag:   $RPGTag\n")
unless !defined $RPGTag;
}
}

$::Options{debug} && msg("process_dir:   $processdir\n");

if ( $::Options{processall} || $processdir ) {

$::Options{info} && msg("Processing dir: $dir\n");

# run metaflac on all target files in present
directory
system( $metaflaccmd, @flacargs, @target_files );
}
}

# process any subdirs of present directory
if (@subdirs) {
&process_dirs(@subdirs);
}
}
}

sub showusage {
print "Usage goes here\n";
exit 1;
}

sub msg {
my $msg = shift;
print "$msg";
}

# vim: autoindent
# vim: textwidth=78
# vim: backspace=indent,eol,start
# vim: tabstop=4
# vim: expandtab
# vim: shiftwidth=4
# vim: shiftwidth=4:
# vim: softtabstop=4:


-- 
priordan
------------------------------------------------------------------------
priordan's Profile: http://forums.slimdevices.com/member.php?userid=20422
View this thread: http://forums.slimdevices.com/showthread.php?t=53539

_______________________________________________
ripping mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/ripping

Reply via email to