|
audio_rename - rename an audio file via information got via L |
audio_rename - rename an audio file via information got via the MP3::Tag manpage.
audio_rename -csR -@p "@a/@l/@02n_@t" .
renames all the audio files in this directory and its subdirectories into a 3-level directory structure given by Artist_Name/Album/Filename, with the basename of Filename being the 2-digit track number separated from the title by underscore.
audio_rename -KD *.wav
Reports how it would rename the *.wav files in this directory according to the default -p rule, but without protectiing ``funny'' characters. Will not do actual renaming.
audio_rename -sc *.mp3
Rename the *.mp3 files in this directory according to the default -p rule, translating cyrillic characters into Latin ``equivalents'', shortening the names of long components, and protecting ``funny'' characters.
audio_rename -p '%a/%{d0}/%B' -G '*/*.mp3'
Assuming one-level subdirectory structure dir/filename.ext, finds files with extension .mp3, and ``sorts'' them into a two-level subdirectory structure; toplevel directory is based on the ``artist'' field, the remaing level is preserved.
audio_rename -p '%a/%{d0}/%B' -R .
Likewise, but does not suppose any particular depth of the current directory structure; only the filename and the most internal directory name are preserved.
audio_rename -p '%a/%N' -R .
Likewise, but all directory names (inside the current directory) are preserved.
The script takes a list of files (or, with -R option, directories) and renames the given files (or audio files in the directories) according to the rules specified through the command line options. File extensions are preserved (by default).
Some ``companion'' files (i.e., file with the same basename, and with an extension from a certain list) may be renamed together with audio files. A lot of care is taken to make the resulting file names as portable as possible: e.g., ``funny'' characters in file names are dumbed down (unless requested otherwise), long filename components may be shortened to certain limits.
A care is taken so that renaming will not overwrite existing files;
however, on OSes which allow rename() to overwrite files, race
conditions can ruin the best intentions. E.g., do not run several
``overlapping'' rename procedures simultaneously!
General use options:
TARGET_FILENAME_PATTERNMP3::Tag method interpolate(). Default
is %02n_%t; this uses 2-digit track number separated from the title
by underscore.
.ext1|.ext2|...|-separated list of associated extensions; when renaming
source.mp3 to target.mp3, the similar rename will be done to
files with the same basename, and extensions .ext1, .ext2, etc.
Defaults to .inf|.tag|.id3.
%E). If present,
the pattern of -p is the complete file name. Behaviour with
non-empty list of associated extensions is not defined.
The following options have the same meaning as for script mp3info2
(?i:\.mp3$): will find files ending in .mp3
(ignoring the case). Note that this expression is put into a
case-ignoring regular expression, so if you want it to be
case-sensitive, protect it as in (?-i:REGEXPR).
option_letters\\, \n, \t are
interpolated. Default is none.
@ by % in option values. (May be useful since -p and
-P may have a lot of embedded characters %, which may be hard to
deal with on some shells, e.g., DOSISH shells.)
patternsconfig_optionsFile name portability options:
mkisofs -J --joliet-long, at least of version 2.01a32). The limit
may be modified per AUDIO_MAX_FILENAME_LEN environment variable.
Note that ``components'' are parts separated by a literal character /
in the given pattern (not slashes coming from interpolated strings).
Note that this utility performes very similarly to mp3info2 utility
when the latter one is used with -p option; only instead of
printing the result of interpolation of -p, it uses the result as
the target file name for renaming (after some ``sanitizing'' of the
result). (However, the defaults for -E options differ!)
Please take into account that the option -P is provided for
completeness only. If one needs really complicated parsing rules to
deduce the resulting file name, it is much safer to use mp3info2
utility to set the wanted file name into some ID3v2 frame (such as
TXXX[wanted-target-name]), and then, after checking for errors, use
this result similar to
audio_rename -p "%{TXXX[wanted-target-name]]}" -R .
After rename, one can delete this frame from the resulting files.
If you want to be absolutely error-prone, preserve the initial file name inside the files by doing something similar to
mp3info2 -@F "TXXX[orig-fname]=@A" -R .
before the rename. If worst comes to worst (but no race conditions happend, so files are not overwritten), one should be able to restore the status quo by running
audio_rename -@p "@A" files_or_directories_list
(giving -R option if needed).
With -R option, there might be situations when the scan of subdirectories first finds a source file in some directory, renames it, then continues the scan of other subdirectories, and will find the target file, so will try to rename it again.
In practice, I do not recall ever encountering this situation; if the target file name depends only on the contents of the file, and not its name, then the second rename will be tautological, so not visible.
Ilya Zakharevich <cpan@ilyaz.org>.
MP3::Tag, MP3::Tag::ParseData, mp3info2
|
audio_rename - rename an audio file via information got via L |