-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharename.in
1853 lines (1218 loc) · 59.1 KB
/
arename.in
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!@@perl@@
use warnings;
use strict;
# Open all other files as UTF-8.
use open qw{ :encoding(utf8) };
# Setup stdin, stdout and stderr according to locale.
use open qw{ :std :locale };
use ARename;
# documentation
=pod
=head1 NAME
arename - automatically rename audio files by tagging information
=head1 SYNOPSIS
arename [OPTION(s)] FILE(s)...
=head1 OPTIONS AND ARGUMENTS
=over 8
=item B<--ambiguous-use-first>
Sets the I<ambiguoususefirst> option. See below for details.
=item B<--compare-versions>
Prints the version of the arename script and the version of the Perl module,
that contains most of the code. These versions should be the same. If not,
that would indicate a possibly broken installation.
=item B<--copy> (short option: B<-c>)
Copy files instead of renaming (moving). This can be useful to copy tracks
from your audio archive to a portable device for example.
=item B<--debug>
Enable debugging output. This actually sets `I<verbosity>' to 10000. This output
option will cause very noisy output. You probably want something less verbose,
like `I<--verbosity 20>'.
=item B<--disable-hooks> (short option: B<-H>)
Do not make use of hooks of any sort (neither global nor local ones).
=item B<--disable-profiles> (short option: B<-N>)
Do I<not> use L<configuration profiles|/Configuration profiles> (see below).
Overwrites the B<useprofiles> setting.
=item B<--dryrun> (short option: B<-d>)
Go into dryrun mode. This means, that no action will be taken. B<arename>
will print what it would do, if called without I<-d>.
=item B<--enable-hooks>
Explicitly enable hooks.
=item B<--force> (short option: B<-f>)
Overwrite files if needed.
=item B<--help> (short option: B<-h>)
Display a short help text.
=item B<--list-cfg> (short option: B<-L>)
List the current configuration in the actual configuration format.
=item B<--list-file-types>
Lists all file types currently supported by B<arename>, one type
per line.
=item B<--list-exts-for-type> E<lt>type[,type[,...]]E<gt>
Lists all extensions recognised file name extsionsion for type
B<E<lt>typeE<gt>>, one extension per line. If a list of types is given
as a comma-separated list, extensions for all listed types are listed.
=item B<--list-profiles> (short option: B<-S>)
Print a list of profile names defined in the active configuration.
(This is primarily used by the zsh completion for the I<--profile> option.)
=item B<--read-local> (short option: B<-l>)
Read a local config file (./.arename.local). Overwrites the B<uselocalrc>
configuration setting.
=item B<--stdin> (short option: B<-s>)
Read filenames from stdin after processing files given on the command line.
It reads one file name per line, which means that file names containing
newlines are not supported.
=item B<--version> (short option: B<-V>)
Display version information.
=item B<--verbosity> E<lt>integer-valueE<gt>
Sets the `I<verbosity>' setting to `I<integer-value>'.
=item B<--suppress-skips> (short option: B<-Q>)
When a file is skipped, because its name would not change, this option will
cause B<arename> to suppress any output. This sets the `suppress_skips' option.
Note that if the `I<verbosity>' setting is at a high enough level, you may
still get messages about the file being processed in the first place.
=item B<--rc> E<lt>fileE<gt>
Read I<file> instead of ~/.arenamerc.
=item B<--post-rc> E<lt>fileE<gt>
Read I<file> B<after> ~/.arenamerc and B<before> ./.arename.local.
=item B<--prefix> E<lt>prefixE<gt> (short option: B<-p>)
Define a prefix for destination files.
=item B<--profile> E<lt>profile(s),...E<gt> (short option: B<-P>)
Define a list of one or more profiles to use forcibly, no matter if they
would be activated normally or not.
=item B<--compilation-template> E<lt>templateE<gt> (short option: B<-T>)
Define a template, that will be used for files that contain a compilation
tag.
=item B<--template> E<lt>templateE<gt> (short option: B<-t>)
Define a generic template (for all files that do I<not> contain a
compilation tag).
=item B<--userset> E<lt>I<variable>=I<value>E<gt> (short option: B<-u>)
Set a user defined variable to a given value (see
L</"User defined variables"> below).
=item I<FILE(s)...>
Input files, that are subject for renaming.
=back
A word about option name stability: With I<arename version 3.0> we are now
using Getopt::Long for parsing command lines options. That change was made,
because the meaningful single letter options where used up. Every option is
available via a I<--long-option>. B<That interface will remain stable>. If
changes to the I<--long-option> interface are done, that will happen with an
appropriate deprecation phase, so users can adjust. So, if you want to use
B<arename> in scripts, those are the options you should use. There are
currently no plans of removing or changing any further short options, but there
are no guarantees. If it is indeed better to change a short option, we will do
so.
A list of options that changed from B<arename> I<3.x> to I<4.0> can be found in
the project's CHANGES file and general advice about incompatible changes from
major version to major version are documented in the UPGRADING file.
=head2 Deprecated Command Line Options
The following options are deprecated and will be removed in a later version of
B<arename>.
=over 4
=item B<--quiet>
This option is a short hand for "--verbosity 10".
=item B<--uber-quiet>
This option is a short hand for "--verbosity 5".
=item B<--verbose>
This is a short hand for "--verbosity 20".
=back
=head1 DESCRIPTION
B<arename> is a tool that is able to rename audio files by looking at
a file's tagging information. It uses this information to assemble a
consistent destination file name. The user can define the format of the
destination filename by the use of template strings.
Templates can be defined in the L</Configuration files>, by the
I<template> and I<comp_template> settings (See L</SETTINGS> below).
By default, B<arename> will refuse to overwrite destination files,
if the file in question already exists. You can force overwriting by
supplying the B<--force> option.
In order to see what would happen instead of actually modifying files, you
can use the B<--dryrun> option. This way you can avoid problems, that would
occur if the situation (e.g. the information in the files or your
configuration) is not exactly as you expected it.
=head2 Supported file formats
Since version 4.0, B<arename> supports a lot more file formats than it
used to (version 3.0 only supported I<.mp3>, I<.ogg> and I<.flac>
files). Thanks to Audio::Scan, we now support a much wider range of
file types, of which most may exist using different file name
extensions (e.g. I<*.ogg> and I<*.oga> are both of the type I<ogg>).
You may use the `I<--list-file-types>' and `I<--list-ext-for-type>'
options to find out which file type is mapped to which file name
extensions.
If you would like support for another file type in B<arename>, you
will have to persuade the Audio::Scan developers to extend their
module with said feature. Adding support for it in B<arename> after
that should be trivial.
To give you an idea, arename (in connection with Audio::Scan B<0.85>)
lets you rename I<mp3>, I<mp4>, I<aac>, I<ogg>, I<flac>, I<asf>,
I<musepack>, I<monkey audio>, I<wav> (this type also supports I<aiff>)
and I<wavpack> files.
=head2 Inputting a *lot* of files
B<arename> can be used to keep the file names of whole audio archives in
sync. However, that means that you will have to tell the script the
location of many files, thousands maybe.
In order to do that you will face the problem, that on most UNIX-like
systems, the length of the argument list for external programs is limited
(recent Linux versions, as an exception, do not have that limitation
anymore).
So, even if your shell can do recursive globbing like ksh or zsh, this will
most likely get you into trouble (for more than just a few files):
% arename -d **/*.mp3
There are several ways to overcome that limitation, of course.
The first solution is to use B<find> in connection with B<arename>'s I<-s>
option:
% find . -name "*.mp3" -print | arename -d -s
This will break for file names that contain newlines, because I<--stdin> will
read one file name per line from the standard input stream.
Another way of using B<find> to deal with this problem is to use find's
I<-exec> option:
% find . -name "*.mp3" -exec arename -d '{}' '+'
This will work for every possible file name. No matter if it has spaces
or newlines in it. The I<+> at the end of the call causes find to call
the external program (B<arename> in this case) with as many arguments as
possible, without exceeding the limit. This requires a POSIXly correct
find. GNU find for instance, did not support the I<+> way for a long time.
If you are stuck with an old version, you can exchange the I<+> with a
I<;> (note, that a semicolon B<must> be quoted in any case), or use the
xargs tool instead.
A last solution for zsh users would be zargs (which requires
'autoload zargs' in your zsh configuration):
% zargs -- **/*.mp3 -- arename -d
=head1 GENERAL USAGE
When you are first confronted with B<arename> and you try to get started
with the documentation you might argue, that a 1000+ lines manual, that
is not filled with too many examples is hardly starter-friendly.
Therefore, this section was introduced to give you the bare minimum of
information in order to use the program without going through too much
fuzz.
If you are really afraid of documentation, you could of course just read
the output of the I<--help> option and see which options to provide in order
to get what you want. Then again, you will soon be pissed by the weird
default values B<arename> uses.
You will probably want other templates. After all, the ability to have
these expanded strings is one of the points to use B<arename> in the first
place. They are described in the TEMPLATE section; and reading that
section is the minimum effort you will want to go through.
After that, you can open the file I<~/.arenamerc> in your favourite
text editor and resemble the following text (and presumably change the
few values in there to your liking):
# now you certainly want your own templates, so define them here
# one for your normal files
template &artist - &album - &tracknumber. &tracktitle
# and another one for files that orignate from compilations
comp_template va - &album - &tracknumber. &artist - &tracktitle
If you want more automation or more customization, you will not get
around reading the manual below. If you need to solve special
problems, the L</HOOKS> part even further below is for you.
=head1 ENVIRONMENT VARIABLES
=over 8
=item B<ARENAME_LOAD_QUIET>
When set to I<1>, B<arename> will not output any startup messages; not
while reading the configuration or hook files, nor will B<arename> emit
messages about whether it is in copy mode or on a dry-run or similar.
However, if warnings or errors are encoutered while loading the
configuration, those messages are still emitted, of course.
Any other value but I<1> - and that includes ARENAME_LOAD_QUIET being
absent from the environment - will cause B<arename> to start up in
its normal manner.
=item B<ARENAME_SUPPRESS_COLOURS>
When set to I<1> (and only 1 - B<arename> will ignore any other setting),
arename will turn off its output colourations. As of version 4.0, B<arename>
uses Term::ANSIColor to produce output, that features terminal colours.
=back
=head1 FILES
B<arename>'s behaviour can be altered by a number of files it reads when
starting up.
Normal configuration tasks are done in (how convenient)
L</Configuration files>, described below.
If you need more control, or want to solve special problems you are having,
you can do so by supplying Perl code in L</Hook definition files>.
B<arename> can be configured to read configuration files as well as hook
definition files from the current working directory. This feature is
disabled by default, because they can be a security issue on multiuser
systems.
There are no such things as system wide configuration files in B<arename>.
For all setup files B<arename> tries to find (except for the local ones)
four different locations are tried. If the I<$XDG_CONFIG_HOME/arename>
directory exists, B<all> files are expected to be there. If that directory
does not exist, I<~/etc/arename/> and if that is not there I<~/.arename> are
are tried instead. If those directories could not be found either, B<arename>
will try to find the file it is looking for directly in the user's home
directory.
The default for I<$XDG_CONFIG_HOME> is I<~/.config>.
The first setup directory we find always wins. B<arename> does not consider
more than one setup directory.
If, for example, I<~/etc/arename/> exists and we are looking for the normal
L<configuration file|/Configuration files> (see below), but
I<~/etc/arename/rc> could not be found, we do B<not> try to find it in
I<~/.arename/> or the user's home directory.
=head2 Configuration files
B<arename> uses up to three configuration files. As for most programs,
the script will try to read a configuration file, that is located in the
user's I<home directory>. In addition to that, it will try to load I<local>
configuration files, if it finds appropriately named files in the
I<current directory> (and the I<uselocalrc> feature is enabled):
=over 8
=item B<$XDG_CONFIG_HOME/arename/rc>
=item B<~/etc/arename/rc>
=item B<~/.arename/rc>
=item B<~/.arenamerc>
per-user normal configuration file.
=item B<./.arename.local>
per-directory local configuration file (only read if I<uselocalrc> is set
or the I<--read-local> option is given on the command line).
=back
The per-user normal configuration file can be substituted by another file,
if specified via the I<--rc> option.
Last but not least, you can specify an intermediate configuration file,
that is read in between the normal and the per-directory file, via the
I<--post-rc> option.
=head3 File format
The format of the aforementioned files is pretty simple.
It is parsed line by line. Empty lines, lines only containing whitespace
and lines, whose first non whitespace character is a hash character (I<#>)
are ignored.
There are two different types of settings: boolean and scalar settings.
Booleans can be set like this:
<setting> [true|false]
If the value is omitted, I<true> is assumed. I<true> and I<false> are
recognized case insensitively, and a value of I<1> is synonymous to I<true>,
as is I<0> to I<false>.
Scalar settings are done in a very similar way:
<setting> <value>
If the value is omitted, string values will be set to an empty string and
numeric values will be set to zero.
In both cases, setting and value are separated by one or more whitespace
characters. The value will be the rest of the line (all of it, including
trailing whitespace).
If the value part starts with a backslash, that backslash is left out of the
value. That makes it possible to define templates with leading whitespace.
If a line contains only a string within square brackets, that string is the
start of a section. Section names are matches for starts of file names.
That means, the settings following such a section definition will only
applied for input file names that start with the same string as the section
name. Where file name means the string, handed over to B<arename>. The string
I<~/> at the beginning of a section name is expanded to the user's home
directory.
You may start as many sections as you would like.
A section named I</foo/bar/> supersedes a section named I</foo/> for a file
named I</foo/bar/baz.ogg>. So, the longest match wins.
Another possible configuration file entry is a user variable, which is
defined via the B<set> command. These settings are very different from the
normal settings. Therefore, they are defined in a different way. That way
is described in the L</User defined variables> subsection below.
Last but not least, you may define so called
L<profiles|/Configuration profiles>, see below.
=head3 Configuration profiles
Profiles are a very flexible and context sensitive way of using multiple
configuration files at once. With profiles, local configuration files (and
local hook definition files) can be substituted in a secure way; even on
multi-user systems.
Reading local files (configs and hook-files) is still supported for backwards
compatibility (see I<uselocalrc> and I<uselocalhooks> L<options|/SETTINGS>).
However, you are strongly encouraged to use profiles whenever you can.
As normal configuration files and global hook-files, profile-related files are
searched in one of the setup directories described above. They are using the
following naming conventions:
=over 8
=item B<$XDG_CONFIG_HOME/arename/profile.PROFILENAME>
=item B<~/etc/arename/profile.PROFILENAME>
=item B<~/.arename/profile.PROFILENAME>
=item B<~/.arename.PROFILENAME>
Profile related configuration files; read if I<PROFILENAME> is active.
They are read after a intermediate config file defined by I<--post-rc> and
a local config file (if enabled).
=item B<$XDG_CONFIG_HOME/arename/profile.PROFILENAME.hooks>
=item B<~/etc/arename/profile.PROFILENAME.hooks>
=item B<~/.arename/profile.PROFILENAME.hooks>
=item B<~/.arename.PROFILENAME.hooks>
Profile related L</Hook definition files> (see below for details); read if
I<PROFILENAME> is active.
These files are read, between global and local hook-definition files.
=back
In order to define profiles, you need to use the I<profile> keyword:
profile <name> <pattern>
Where I<name> is a string, that is used in the place of B<PROFILENAME>
in the file location lists above. This name may contain of the following
character range: B<a-zA-Z0-9_->
I<pattern> is part of a Perl regex pattern (see I<perlreref> and I<perlretut>
manpages). The pattern will be anchored at the beginning and is open at
the end, somewhat like this pseudocode:
if ($working_directory =~ m/^PATTERN/) { use_this_profile(); }
Example:
profile music /mnt/audio/music/
Will cause the profile I<music> to be active when the working directory is
I</mnt/audio/music/> or below. So, do not be afraid. You can use profiles
without understanding regular expressions.
Like many other values in B<arename>'s configuration, a leading backslash of
a pattern will be ignored to allow patterns, that start in white spaces.
Furthermore, if a pattern starts in I<~/>, that string is replaced by the
user's home directory.
You may add as many patterns to a profile name, as you want:
profile music /mnt/audio/music/
profile music /mnt/extern/audio/music/
The above activates the I<music> profile in I</mnt/audio/music/> and
I</mnt/extern/audio/music/>, for example.
More than one profile can be activated at the same time. If that is true,
the according configuration files are read in lexical order.
=head3 Sections versus Profiles
Since B<arename> provides two context sensitive configuration facilities,
you might ask yourself when to use which, when you are confronted with both
for the first time.
First of all, I<profiles> are more powerful. They may even introduce new
hooks for B<arename> to use. But that is not the conceptual difference
between the two.
I<sections> are sets of configuration settings, that are considered for
B<each and every> input file and they are B<only> enabled for input files,
whose name matches the section name.
I<profiles> on the other hand are sets of configuration and hook-definition
files, whose inclusion in the current B<arename> run is decided at the
B<beginning> of the program's execution (not for every input file) - namely,
if the name of the current working directory matches one of the profile's
patterns.
That means, that if you need to introduce slight configuration changes based
on an B<input file's name> you want to use a I<section>.
If you need to make broader configuration changes, considering the name of
the B<current working directory>, I<profiles> are the way to go.
Of course, profile configuration files may introduce new sections, too.
=head2 Configuration file example
# switch on verbosity
verbosity 20
# canonicalize file names before working with them
canonicalize
# the author is crazy! use a sane template by default. :-)
template &artist - &album (&year) - &tracknumber. &tracktitle
# activate the 'music' profile below /mnt/audio/music/.
profile music /mnt/audio/music/
# force files from /foo/bar/ to stay below that directory
[/foo/bar/]
prefix /foo/bar
=head2 Hook definition files
=over 4
=item B<$XDG_CONFIG_HOME/arename/hooks>
=item B<~/etc/arename/hooks>
=item B<~/.arename/hooks>
=item B<~/.arename.hooks>
Defines global hooks, that are in effect in every directory if the I<usehooks>
option is set to B<true>.
=item B<./.arename.hooks.local>
This allows you to define special hooks, that will only be applied for processes
that run in the directory the local file is found (and if the I<uselocalhooks>
option is set to B<true>).
=back
For details about hooks in B<arename>, see L</HOOKS> below.
=head1 SETTINGS
The following settings are supported in all configuration files.
Not all of them are usable in I<sections>. The ones you can use in
sections are: All I<default_*> options, I<force>, I<prefix>, I<sepreplace>,
I<tnpad>, I<comp_template> and I<template>.
=over 8
=item B<ambiguoususefirst>
Some tag types support setting the sametag multiple times. The
scanning backends before arename 4.0 did not support such tags. When
this option is set to I<false> (default), arename gives up when it
encounters such tags.
When set to I<true>, arename just uses the first value it encounters.
For maximum control over how tags with ambiguous values are handled,
you may use the `I<ambiguoustag>' hook. (default: I<false>)
=item B<canonicalize>
If set, a given file name will be transformed to its cleaned up absolute
path. You may want to set this, if you are using sections in the
configuration. If you do not use sections, all this will give you is a
performance penalty. (default value: I<false>)
=item B<checkprofilerc>
If set, B<arename> will check if there is a configuration file for a
profile as soon as it reads a profile definition in the setup and B<only>
consider the profile if it found the according config file. Profiles
without config file will cause a warning if this is set, which may cause the
I<dryrun> option to be set if the I<warningsautodryrun> option is set.
If unset, profiles without config file will not cause warnings. You will
see messages about missing configuration files, if a profile without config
file is active. (default: I<true>)
=item B<checktemplatesinitially>
If set, B<arename> will inspect all I<template> and I<comp_template>
settings for possible problems. Unsetting this option probably only
makes sense, if you are working with templates within hooks and know
what you are doing. Normal users will most likely want to stick with
the default. (default: I<on>)
=item B<comp_template>
Defines a template to use with files that provide a compilation tag
(for 'various artist' CDs, for example). This setting can still be
overwritten by the B<--compilation-template> command line option. (default
value: I<va/&album/&tracknumber - &artist - &tracktitle>)
=item B<default_*>
default_artist, default_album, default_compilation, default_genre,
default_tracknumber, default_tracktitle, default_year
Defines a default value, for the given tag in files, that lack this
information. (default value: I<undefined>)
=item B<hookerrfatal>
If this is set to false, arename will continue execution even if
reading, parsing or compiling a hooks file failed. (default value:
I<false>)
=item B<prefix>
Defines a prefix for destination files. Setting this to '/foo/bar' results
in destination files named '/foo/bar/Expanded Template.ogg'
This setting can still be overwritten by the B<--profile> command line option.
(default value: I<.>)
=item B<sepreplace>
Tagging information strings may contain slashes, which is a pretty bad
idea on most file systems. Therefore, you can define a string, that replaces
slashes with the value of this setting. (default value: I<_>)
=item B<suppress_skips>
Like the `I<--suppress-skips>' command line option, this disables messages for
files that B<arename> will skip because the file name would not change.
=item B<template>
Defines a template to use with files that do not provide a compilation tag
(or where the compilation tag and the artist tag are exactly the same).
This setting can be overwritten by the B<--compilation-template> command
line option. (default value:
I<&artist[1]/&artist/&album/&tracknumber - &tracktitle>)
=item B<template_aliases>
If this option is set, B<arename> allows the use of abbreviated taq
names in I<template> and I<comp_template>. See L</Available expression
identifiers> below for details. (default value: I<off>)
=item B<tnpad>
This defines the width, to which the track number field is padded with zeros
on the left. Setting this to zero disables padding. (default value: I<2>)
=item B<usehooks>
If set to true, use hooks defined in B<~/.arename.hooks>.
(default value: I<true>)
=item B<uselocalhooks>
If set to true, use hooks defined in B<./.arename.hooks.local>.
(default value: I<false>)
=item B<uselocalrc>
If set to true, read a local configuration file (B<./.arename.local>),
if it exists. (default value: I<false>)
=item B<useprofiles>
If set to true, configuration profiles will be used. If false, they are not.
(default value: I<true>)
=item B<usetypeasextension>
One file type may be used for different file name extensions. For
example, files matching I<*.ogg> and I<*.oga> will both be handled as
type I<ogg> in Audio::Scan (the information gathering backend,
B<arename> is using since version 4.0).
When this option is set to I<true>, a file matching I<*.oga> would be
renamed using I<.ogg> as the extension, since its type is
I<ogg>. Otherwise, the original extension is left untouched. (default:
I<true>)
=item B<verbosity>
Integer option, that sets the verbosity of I<arename>'s output. The default
value is `I<10>'. The `I<--verbosity>' option may be used to override this
setting.
=item B<warningsautodryrun>
Switches on the I<dryrun> option (if not enabled already), as soon as the
configuration file parser encounters non-fatal warnings. This option was
introduced to avoid destructive behaviour due to incorrect lines in any
of the configuration files. (default value: I<true>)
=back
=head2 Deprecated Settings
=over 4
=item B<verbose>
This setting has no effect and will be removed in a later version. Use an
appropriate `I<verbosity>' setting instead.
=item B<quiet>
This setting has no effect and will be removed in a later version. Use an
appropriate `I<verbosity>' setting instead.
=item B<quiet_skip>
This setting has no effect and will be removed in a later version. Use an
appropriate `I<verbosity>' setting instead.
=item B<debug>
This setting has no effect and will be removed in a later version. Use an
appropriate `I<verbosity>' setting instead.
=back
=head2 User defined variables
You can use the B<set> command in arenamerc files. This way the user can
define his own variables. The namespace is separate from B<arename>'s
normal settings. (That means, you cannot, for example, overwrite the
internal I<template> variable with this command.)
The sytnax is quite simple (and B<different> to normal settings on purpose!):
B<set> I<varname> = I<value>
There may be an arbitrary amount of whitespace around the equal sign
(including no whitespace at all). If you want to have a value that
starts in a whitespace character, you may start the value with a
backslash character (just like with the normal settings, a leading
backslash is always ignored).
You may also set user defined variables on the command line by using the
I<--userset> option:
% arename --userset variable0=value
% arename -u variable0=value
User defined variables are useful to make hooks configurable (see
L</HOOKS> below). Starting with version 4 of B<arename>, user defined
variables may also be defined within sections, which (just like normal
option) makes them applicable only if said section is used for a given
file.
=head1 TEMPLATE FORMAT
B<arename>'s templates are fairly easy to understand, but powerful.
At simplest, a template is just a fixed character string. However,
that would not be exactly useful, because then every file you would
ever want to rename would be getting the exact same name. That is why
B<arename> is able to expand certain expressions with information
gathered from the file's tagging information.
An expression basically looks like one of the following forms:
=over 8
=item B<&>I<identifier>
This is the `B<trivial>' expression. It will expand to the information
stored within the corresponding tag. If the tag in question is not
available, the expansion of the template string will fail.
=item B<&>I<identifier>B<[>I<length>B<]>
The `B<sized>' expression. The I<length> modifier in square brackets
defines the maximum length, to which the expression should be
expanded.
That means, if the artist of a file reveals to be 'I<Frank Zappa>',
then using 'B<&artist[1]>' will expand to 'I<F>'.
=item B<&{>I<identifier>B<:>I<default-template>B<}>
This is the first complex expression, called `B<complex-default>'. When
the tag, which corresponds to `I<identifier>' is available, this
expression will expand exactly like the trivial expression would.
If it is B<not> available though, the expansion doesn't fail, but
instead the `I<default-template>' string is expanded.
=item B<&{>I<identifier>B<?>I<set-template>B<!>I<unset-template>B<}>
This expansion is called `B<complex-set-unset>'. Again, what will be
used during template expansion depends on whether the tag which
corresponds to `I<identifier>' is set or not.
If it is B<set>, the string I<set-template> is expanded; if it is
B<unset>, the I<unset-template> string is used.
=back
Both simple expansions may be used with braces, like the complex
expansions are:
=over 8
=item B<&{>I<identifier>B<}>
This is equal to `B<&identifier>'.
=item B<&{>I<identifier[length]>B<}>
And this is equal to `B<&identifier[length]>'.
=back
Backslashes are special in template strings, because they are used to
quote characters that bear special meaning (for example, to get a
ampersand character, you need to use "B<\&>"). To get an actual
backslash in the resulting string, you need to use a backslash, quoted
by a backslash. A backslash on non-special characters is silently
dropped.
=head2 Nesting expressions
In complex expressions, the strings called `I<default-template>',
`I<set-template>' and `I<unset-template>' are subject to regular
template expansion. Hence, expressions like the following are
possible:
"&{album?&album/!}"
If `B<album>' were set, it would expand to its value followed by a
slash; otherwise it would expand to nothing. Using this, it is fairly
easy to deal with album-less tracks:
"&artist/&{album?&album/&tracknumber. !-no-album-/}&tracktitle"
That will effectively use the following template if `B<album>' is set:
"&artist/&album/&tracknumber. &tracktitle"
But if it is not set, it will instead use this:
"&artist/-no-album-/&tracktitle"
Caution has to be taken if certain characters are to be used within
conditional template expressions. For example, to use a closing curly
bracket in either of them, it needs to be quoted using a backslash
character.
Similarly, if an exclamation mark is to be used in a
`I<set-template>', it needs to be quoted by a backslash to avoid the
character being interpreted as the end of the `I<set-template>'
string.
=head2 Available expression identifiers
The data, that is expanded is derived from tagging information in the
audio files. There are two kinds of information available. One is the
purely informational tag (like a track's artist) and the other further
describes the format of the audio file (like the file's bitrate).
If you are defining a lot of templates on the command line, you may
find that these identifiers take quite a while to type. If the
I<template_aliases> option is set, you may use shorter alias names
instead of the the real identifier. Available aliases are listed with
their corresponding idetifier below.
This is a list of all informational identifiers available for
B<all> file-types:
=over 8
=item B<album>
The album the currently processed track is part of. (alias: I<al>)
=item B<artist>
The artist for the current track. (alias: I<ar>)
=item B<compilation>
Compilation tags are not very stable across different file
types. Usually, this is set to a string like "I<Various Artists>" for
tracks that are part of some sort of compilation album (like motion
picture sound-tracks). (alias: I<cmp>)
=item B<genre>
The genre or content type of the audio file. (alias: I<gn>)
=item B<tracknumber>
The number of the position of the track on the disc. Obviously. However, this
can be in the form of '12' or '12/23'. In the second form, only the part left
of the slash is used. The tracknumber is a little special, as you can define
to what width it should be padded with zeros on the left (see I<tnpad> setting
in L</SETTINGS>). (alias: I<tn>)
=item B<tracktitle>
The title of the currently processed track. (alias: I<tt>)
=item B<year>
Chronological information about the track (usually the year a song was
written or the year the album a track is part of was
released). (alias: I<yr>)
=back
Here is a list of file-format information tag available for B<all>
file-types:
=over 8
=item B<bitrate>
The bitrate the file was recorded/encoded with. (alias: I<br>)
=item B<channels>
The number of channels available in the file (for example, this is `2'
for stereo files). (alias: I<ch>)