ClI tool / library to store tags directly in the filenames (ex: test#foo.txt
).
I wanted to tag my files to retrieve them easily on cross platform. I searched a sexy solution like Mac OS has but I didn't find any.
Extended attributes (shortened xattr
) are used to store metadata of the files. It's a simply key/value storage related to a file or a folder.
Linux supports it with EXT4 or ZFS filsystem and MacOS with HFS+ or APFS. But Windows (with NTFS) does not support it.
Extended attributes is an hackable solution since they can be used thought CLI tools xattr
. Thus you can easily write them using setfattr
and read them using setfattr
1.
It doesn't fit my need because:
- extended attributes are not saved into the file. It means that even
cp
doesn't copy extended attributes when file move to a different storage (apparently you need to usersync -X
instead...). TODO verify - This is not possible on Android. I tried using Termux on Android and I got unsupported error
- They are not saved in every cloud provider / FS types 2
TagScape is a cross-platform open-source software which offer two approach to tags files everywhere.
It offers two way to handle tags:
- filename, The first approach is really simple. If you want to add tag
work
tofoo.txt
, you simply rename your filefoo[work].txt
. That's it. It seems dumb at first but it's not. - sidecar, The first approach is to add a JSON by the file. So if you want to tag
foo.txt
, TagSpace will create a filefoo.txt.json
.
It doesn't fit me because the filename convention they use is not really hackable for me. It's difficult to find a tag using the search tool in Nautilus for example.
A common idea is to use symbolic links to tag your files.
For instance, you create a top level folder tags/
. if you want to tag your file foo.txt
as work
, you simply create a new folder tags/work
and make a symlink
./tags/work/foo.txt -> ./foo.txt
It is easy to script using a shell script. But it doesn't work on Android. Also, symlink are weak and may be broken if your rename/move/destroy the original file.
Footnotes
-
Bash script example to read/write EXT4 extended attributes https://bougui505.github.io/2017/09/12/tagging_files_using_ext4_extended_file_attributes.html ↩
-
https://eclecticlight.co/2018/01/12/which-file-systems-and-cloud-services-preserve-extended-attributes/ ↩