=pod
=for html
=head1 NAME
squaretag - tag files by using filenames
=head1 SYNOPSIS
squaretag add [--verbose|-v] [--dry-run|-n] [--force|-f] TAG FILES...
squaretag remove [--verbose|-v] [--dry-run|-n] [--force|-f] TAG FILES...
squaretag clear [--verbose|-v] [--dry-run|-n] [--force|-f] FILES...
squaretag rename [--verbose|-v] [--dry-run|-n] [--force|-f] OLD_TAG NEW_TAG FILES...
squaretag list FILES...
squaretag search SEARCH FILES...
squaretag untagged FILES...
=head1 DESCRIPTION
Squaretag helps you to organize your files by tagging them. The tags
are saved in the filename by adding all tags in square brackets either
at the end of the filename or just before the last dot.
=head1 EXAMPLES
Suppose the current directory contains the following files:
$ squaretag untagged
picture01.jpg
picture02
Now you want to add the tag I to all pictures.
$ squaretag add -v family *
picture01.jpg -> picture01[family].jpg
picture02 -> picture02[family]
Files can have multiple tags
$ squaretag add -v myself picture01[family].jpg
picture01[family].jpg -> picture01[family,myself].jpg
You can rename single tags
$ squaretag rename -v myself me picture01[family,myself].jpg
picture01[family,myself].jpg -> picture01[family,me].jpg
Or delete a tag
$ squaretag remove me -v picture01[family,me].jpg
picture01[family,me].jpg -> picture01[family].jpg
And what would tags be good for if you couldn't search for them
$ squaretag search 'family && !me' *
picture02[family]
And if you have enough, you can simple clear all tags
$ squaretag clear *
picture01[family].jpg -> picture01.jpg
picture02[family] -> picture02
Tags can also have values:
$ squaretag add read=2016 book.epub
$ squaretag search 'read>2010' *
books[read=2016].epub
$ squaretag search 'read<2010' *
$ squaretag search 'read=2016' *
books[read=2016].epub
=head1 COMMANDS
=over 4
=item add TAG FILES...
Add TAG to FILES. TAG is a comma seperated list of tags to add. If
a tag has a suffix of I<-> this tag will be removed from the file.
=item remove TAG FILES...
Remove TAG from FILES. TAG is a comma seperated list of tags to remove. If
a tag has a suffix of I<+> this tag will be added to the file.
=item search SPEC FILES...
List all FILES that match the search SPEC. SPEC can contain tags and
the usual boolean operators.
For example:
read && good
!read || (not_read && prio )
There are three additional operators I<<>, I<=> and I<>> to handle tags
with values. The I<=> compares its operand as strings, the other two
just work on numerical tags.
=item clear FILES...
Remove all tags from FILES.
=item rename OLD_TAG NEW_TAG FILES...
Rename OLD_TAG in NEW_TAG in all FILES.
=item list FILES...
List and count all tags for FILES. The tags are sorted in descending
order of frequency.
=item untagged FILES...
List all FILES without a tag.
=back
=head1 RATIONALE
Tagging files in a way that tags are preserved cross-platform or even
cross-filesystem seems to be a hard problem with no clear cut solution.
=head2 Fileformat
Some file formats as mp3 or pdf support saving tags inside the files but there
a a lot (probably most) that don't. And even the former need special programs
to do that.
=head2 Filesystem
Many modern file systems support tags and special meta data streams, but the
tags are most likely lost when you copy files from one file system to the next.
=head2 External database
Keeping the tags in a external database requires a sync step after moving or
deleting files. This is harder than it sounds, you probably need the keep
checksums to reckognize known files after a rename.
=head2 Filename
All filesystems limit the length of the filename, so the number of tags
you can save per file is also limited. And even before you reach the
limit, the filename will be hard to read.
But at least it works for all kinds of files, it not dependent on your file or
operating sytemen is does not need external tools or syncing steps.
=head1 SEE ALSO
L, L
=head1 COPYRIGHT AND LICENSE
Copyright 2016 Mario Domgoergen C<< >>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .