Reinventing file storage with semantic tagging
Date2name and Appendfilename
The Date2name tool [7] adds the date and timestamps at the beginning of the file name. The command:
date2name "foo bar.txt"
renames the file to 2019-09-26 foo bar.txt
.
date2name --withtime "foo bar.txt"
would give you 2019-09-26T14.45 foo bar.txt
.
One frequently recurring step when working with files is adding words from the actual file name. If you want to add a description to a photo named 2019-09-26T14.52.36.jpg
, use the Appendfilename [8] tool. The following call:
appendfilename --text="foo bar" 2019-09-26T14.52.36.jpg
renames the file to 2019-09-26T14.52.36 foo bar.jpg
. Without the --text
parameter, the tool waits for text input in interactive mode.
If you wrap the call in a script, as shown in Listing 2, Appendfilename can extend all selected files in a file browser after you enter and confirm the text in the window that appears.
Listing 2
Wrapping Appendfilename
/usr/bin/gnome-terminal \ --geometry=90x5+330+5 \ --hide-menubar \ -x appendfilename "${@}"
Filetags
Like Appendfilename, Filetags [9] adds text to the file name, but without you needing to worry about separators in front of the tags. Both the command in the first line of Listing 3, and the one in the second line result in foo -- bar baz.txt
as the file name. The command form in Line 3 converts back to foo.txt
.
Listing 3
Adding Tags
$ filetags --text "bar baz" "foo.txt" $ filetags --text "baz" "foo -- bar.txt" $ filetags --remove --text "baz bar" "foo -- bar baz.txt"
In interactive mode without the --text
parameter, you can remove existing tags by prepending a minus sign: -bar baz
removes the bar
tag and adds baz
.
The tool also suggests tags based on their use in other files in the same directory. These suggestions assign file tags with numbers starting at 1. You can reuse these abbreviations in your input. For example, interactively inputting 1 bar 42
tells the tool to add suggestions 1, 2, and 4 together with the bar
tag.
In addition, Filetags offers a tab completion option. To manage this, it is a good idea to create a .filetags
file in the current directory or a parent directory. The software searches recursively upwards; the first definition file found wins. This means you can have different definitions for different hierarchies.
The structure of this text file is very simple. Each line consists of one or more tags. If several of them are in one line, Filetags treat them as mutually exclusive. Based on the .filetags
file in Listing 4, if you add a tag of foo -- draft.txt
to a final
file, Filetags will automatically replace the draft
tag with final
instead of appending it.
Listing 4
.filetags File
presentations cheatsheets cliparts finance manuals templates draft final submitted
Guessing and Unpacking
The Guessfilename [10] tool, written in Python, helps to rename frequently used file names. Using pattern recognition in the file name and by parsing the contents where necessary, it determines variants for the file names. If your monthly pay slip is sent in the form of a PDF file such as Salary.pdf
, it recognizes the Salary
character string and the PDF file type by reference to a configured pattern and generates the new file name 2019-09-29 Pay slip September -- finance company.pdf
.
It is in the nature of things that you have to adapt Guessfilename to suit your own needs – it is practically just a template for customization. To customize the crucial derive_new_filename_from_old_filename()
function, you need basic Python programming skills.
To compensate for the overhead, you can look forward to many simplifications in daily file handling. I use Guessfilename not only for pay slips, but also for audio recordings, digital photos directly from the camera, screenshots, invoices, and other files – wherever programs do not let you configure the file name to suit a desired scheme.
The Guess-target-folder.sh
and Move2archive [11] tools take care of the next logical step: moving the files to the appropriate target folder. Both scripts in this form are usually only useful on Unix-style operating systems.
Guess-target-folder.sh
is a trivial, but again highly personalized, shell script. Listing 5 outlines the basic mechanism. Move2archive behaves in a very similar way, but it does not support pattern recognition. It simply moves the files to a folder structure, where the directory names consist of an archivepath
(like $HOME/archive/
) and the year.
Listing 5
Guess-target-folder.sh
# Guess-target-folder.sh # file="${1}" move_file() { file="${1}" targetdir="${2}" echo "* ${file}\n -> ${targetdir}" mv "${file}" "${targetdir}" } case "${file}" in 20*Columbo*mp4) move_file "${file}" "$HOME/tv/detectivestories/";; 20*Meter_reading\ Water*pdf) move_file "${file}" "$HOME/correspondence/wasser/";; *Salary*pdf) move_file "${file}" "$HOME/correspondence/company/";; *1234567*|*1.234.567*) move_file "${file}" "$HOME/correspondence/insurance/";; esac
The two Python scripts can be installed using Pip3 if required. The particularly annoying integration on Windows systems prompted the development of Integratethis [12], which supports easy integration into Windows Explorer. But there is no reason why it should not be taught how to integrate with Geeqie, Thunar and other interfaces. Appropriate pull requests on Github are welcome.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.