pytagsfs — filesystem mapping media files to an arbitrary directory structure
pytagsfs [OPTIONS] {sourcedir} {mountpoint}
pytagsfs is a FUSE filesystem that was designed to present multiple views of tagged media files. For instance, a directory tree containing audio files could be mapped to a new directory structure organizing those same files by album, genre, release date, etc.
To get a feel for what's possible, see the section called “Examples”.
General Options
-o opt[,opt...]mount options
-h, --helpshow summary of options and exit
-v, --versionshow version of program and exit
pytagsfs Options
-o iocharset=ENCODINGmounted tree character encoding (default utf-8)
-o source_iocharset=ENCODINGsource directory character encoding (default utf-8)
-o srcfilteradds a source path filter; may be specified more than once (see the section called “Path Filters”)
-o dstfilteradds a destination path filter; may be specified more than once (see the section called “Path Filters”)
-o formatformat string for destination paths (see the section called “Format Strings”)
-o verbositylog level; must be one of "debug", "info", "warning", "error", "critical"; defaults to "warning"
FUSE Options
-d, -o debugenable debug output (implies -f)
-fforeground operation
-sdisable multi-threaded operation
-o allow_otherallow access to other users
-o allow_rootallow access to root
-o nonemptyallow mounts over non-empty file/dir
-o default_permissionsenable permission checking by kernel
-o fsname=NAMEset filesystem name
-o large_readissue large read requests (2.4 only)
-o max_read=Nset maximum size of read requests
-o hard_removeimmediate removal (don't hide files)
-o use_inolet filesystem set inode numbers
-o readdir_inotry to fill in d_ino in readdir
-o direct_iouse direct I/O
-o kernel_cachecache files in kernel
-o umask=Mset file permissions (octal)
-o uid=Nset file owner
-o gid=Nset file group
-o entry_timeout=Tcache timeout for names (1.0s)
-o negative_timeout=Tcache timeout for deleted names (0.0s)
-o attr_timeout=Tcache timeout for attributes (1.0s)
A format string must be specified for each pytagsfs mount. The format string determines the directory and file names in the resulting virtual filesystem. Format strings contain zero or more special character sequences, much like the date and time format strings supported by date. These character sequences always begin with a percent sign (%).
Substitution sequences consist of a percent sign followed by a single ASCII character, like "%a". When formatting a filename, each sequence will be replaced with a parameter parsed from the file being represented. The parameter that is substituted is determined by the character following the "%".
The following formatting characters are supported:
f name of the original file |
p name of the original file's parent directory |
e extension of the original file |
n track number; concise (like 7) |
N track number; two digits with leading zeros (like 07) |
a artist |
t track title |
l album title |
y year of release |
g genre |
Format strings can be further extended to perform string translations on parameters prior to substitution. Such translations are indicated by the inclusion of a modifier character after the percent sign. For instance, "%^a" indicates an all-caps version of the artist name.
The full list of modifier characters follows:
^ UPPERCASE |
_ lowercase |
! Title Case |
Normally, any file for which a parameter required by the format string cannot be determined is implicitly excluded from the resulting filesystem. Conditionals can be used to express that these files should be included, but that those portions of the format string that cannot be rendered should be omitted or replaced.
Two types of conditional expressions may be used: "if" expressions and "if-else" expressions. The contents of an "if" expression are omitted unless all parameters within that expressions can be successfully evaluated. An "if-else" expression is similar, except that, if the expression does not evaluate, an alternative will be used instead. Use the following syntax:
%?expr%? |
%?expr%:alt%? |
Path filters can be used to limit the set of files presented by the filesystem using regular expressions. Files are filtered by source path or by destination path, inclusively (limiting the set of paths to those that match the regular expression) or exclusively (limiting the set of paths to those that do not match the regular expression).
Use the mount options srcfilter and
dstfilter to filter by source path and destination path,
respectively. Filters are inclusive unless the filter parameter starts
with an exclamation point, in which case the regular expression is assumed
to be the part of the parameter following the exclamation point.
Multiple filters of any kind may be used, and are applied in the order that they are specified on the command line. See the section called “Examples” for some sample filters.
View media files in src, with original filenames in a
flat directory structure:
$ pytagsfs -o format='/%f' src mnt
View media files in src by album on
mnt:
$ pytagsfs -o format='/%a/%f' src mnt
A more complex album-based view:
$ pytagsfs -o format='/%a - %l/%N %a - %t [%l].%e'
This is like above, but filters the result. I use this to display my files by album, but exclude compilations (which I've tagged to include a hyphen in the album name, like "various - album"):
$ pytagsfs -o \ format='/%a - %l/%N %a - %t [%l].%e',\ dstfilter='!^/[^/]* - [^/]* - [^/]*/' \ src albums
I use this to display the compilations:
$ pytagsfs -o \ format='/%l/%N %a - %t [%l].%e',\ dstfilter='^/[^/]* - [^/]*/' \ src compilations
Maybe you only want to see files that start with "a" and end in ".mp3"?
$ pytagsfs -o \ format='/%f',dstfilter='^/a',dstfilter='\.mp3$' \ src mnt