- m2a.py
This script moves items (files or directories) containing ISO datestamps
like YYYY-MM-DD into a directory stucture for the corresponding year.
You define the base directory either in this script (or using the
command line argument --archivedir). The convention is, e.g.:
#+begin_src bash
/2011
/2011/2011-12-20 Meeting Friends at Barleys
/2011/2011-12-20 Meeting Friends at Barleys/Tom with Beer.jpeg
#+end_src
This script extracts the year from the datestamp of each file and
moves it into the corresponding directory for its year:
#+begin_src bash
m2a 2010-01-01_Jan2010.txt 2011-02-02_Feb2011.txt
#+end_src
... moves 2010-01-01_Jan2010.txt to /2010/
... moves 2011-02-02_Feb2011.txt to /2011/
OPTIONALLY: you can define a sub-directory name with option -d DIR. If it
contains no datestamp by itself, a datestamp from the first file of the
argument list will be used. This datestamp will be put in front of the name:
#+begin_src bash
m2a -d "2009-02-15 bar" one two three
#+end_src
... moves all items to: /2009/2009-02-15 bar/
#+begin_src bash
m2a -d bar 2011-10-10_one 2008-01-02_two 2011-10-12_three
#+end_src
... moves all items to: /2011/2011-10-10 bar/
If you feel uncomfortable you can simulate the behavior using the --dryrun
option. You see what would happen without changing anything at all.
For the complete usage help, please use the --help option.
- Target group: users who are able to use command line tools and who
are managing photographs and other event-related files in folder
structures. - Hosted on github: https://github.com/novoid/move2archive
** Why
There is no integrated software solution for managing photographs
that will (a) provide you all of the features you will ever want, (b)
be available for a long period of time, and (c) provide a
future-prove, platform-independent work-flow.
This is the reason I came up with this method of organizing archive
files (photographs, scanned PDF files, memories, ...) in such a
folder structure.
** Installation
Get it from [[https://github.com/novoid/move2archive][GitHub]] or install it via «pip install move2archive».
** Interactive Use
:PROPERTIES:
:CREATED: [2022-01-06 Thu 11:34]
:END:
If you are using =m2a= in an interactive way, you need to know the
following behavior difference when you (1) provide a target directory
and (2) when no specific target directory is provided by you.
Let's use two example files:
- =2020-07-13T13.55 xkcd about PIM.png=
- =2022-01-06 screenshot of my editor.png=
Now let's assume those two files are the only PNG files in the current
directory and the following command line you're using: =m2a *png=
First, let's take a look at the version (1) where you select or enter
a target directory to file to.
*** Selecting a Target Directory
When asked "Please enter directory basename:" in the interactive
prompt you're entering "some images".
This will result in both files moved to the one target directory
where the oldest date-stamp is used to determine the year:
- =/2020/2020-07-13 some images/2020-07-13T13.55 xkcd about PIM.png=.
- =/2020/2020-07-13 some images/2022-01-06 screenshot of my editor.png=.
This is because the files are grouped together to be filed to the same
spot when one single target directory is given.
A handy feature of =m2a= is that it suggest existing folders in the
=archivepath=. So if you already do have a folder like
=/2020/2020-07-13 interesting stuff/= and you call =m2a=
with any file that starts with =2020-07-13...=, it shows a prompt
like:
: One matching target directory found. Enter "1" if you want to use it:
: [1] 2020-07-13 interesting stuff
In the case you want to re-use this directory as the target directory
for the current files , you simply enter =1= to the prompt and the
files are moved to that directory. Isn't that handy?
Now, let's compare with (2) when no target directory is given in the
next section.
*** Not Selecting a Target Directory
This time, you do not enter anything in the target directory prompt
and you do not select a proposed target by entering a numeric
shortcut.
This will result in each file moved to its corresponding yearly archive directory:
- =/2020/2020-07-13T13.55 xkcd about PIM.png=
- =/2022/2022-01-06 screenshot of my editor.png=
*** On the Difference of Behavior
The reasoning behind this different behavior between a specific target
directory is provided and not is that you can use =m2a= to file away a
larger group of files to their yearly archive folders without the need
of filing each one individually or writing a loop command.
However, when you do provide one single target directory, this is used
for all files, independent of their date-stamp (using the oldest
date-stamp).
This might irritate at first but makes perfectly sense if you think
about it or the alternatives.
** Bonus: integrating into Geeqie (or similar file browsers)
I am using [[http://geeqie.sourceforge.net/][geeqie]] for browsing/presenting image files. For quickly
moving files to their folders, I mapped this script to m. This way,
I can go through new image files and move event-related photographs
very quickly.
Using GNU/Linux, this is quite easy accomplished. The only thing that
is not straight forward is the need for a wrapper script. The wrapper
script does provide a shell window for entering the tags.
vk-m2a-wrapper-with-gnome-terminal.sh looks like:
#+begin_src bash
#!/bin/sh
/usr/bin/gnome-terminal
--geometry=157x56+330+5
--hide-menubar
-x /home/vk/bin/m2a --pauseonexit "${@}"
#end
#+end_src
In $HOME/.config/geeqie/applications I wrote a desktop file such
that geeqie shows the wrapper script as external editor to its
image files:
$HOME/.config/geeqie/applications/m2a.desktop looks like:
#+begin_src bash
[Desktop Entry]
Name=m2a
GenericName=m2a
Comment=
Exec=/home/vk/src/misc/vk-m2a-wrapper-with-gnome-terminal.sh %F
Icon=
Terminal=true
Type=Application
Categories=Application;Graphics;
hidden=false
MimeType=image/;video/;image/mpo;image/thm
Categories=X-Geeqie;
#+end_src
In order to be able to use the keyboard shortcuts m, you can define
them in geeqie:
- Edit > Preferences > Preferences ... > Keyboard.
- Scroll to the bottom of the list.
- Double click in the
KEY-column ofm2aand choose
your desired keyboard shortcut accordingly.
I hope this method is as handy for you as it is for me :-)
- Related tools and workflows
--- BEGIN SHARED: filetags_tools --- see https://github.com/novoid/screencasts/
This tool is part of a tool-set which I use to manage my digital files
such as photographs. My work-flows are described in [[http://karl-voit.at/managing-digital-photographs/][this blog posting]]
you might like to read and in the video which is linked above.
In short:
-
For tagging, please refer to [[https://github.com/novoid/filetags][filetags]] and its documentation. It's
the most important part of the whole concept on how I manage files. -
See [[https://github.com/novoid/date2name][date2name]] for easily adding ISO time-stamps or date-stamps to files.
-
For easily naming and tagging files within file browsers that
allow integration of external tools, see [[https://github.com/novoid/appendfilename][appendfilename]] (once more)
and [[https://github.com/novoid/filetags][filetags]]. -
Moving to the archive folders is done using [[https://github.com/novoid/move2archive][move2archive]].
-
Naming files is tedious. Therefore, I wrote [[https://github.com/novoid/guess-filename.py/][guessfilename]]:
Python-script, guesses according to file name, optional PDF content,
optional video json metadata. -
Having tagged photographs gives you many advantages. For example, I
automatically [[https://github.com/novoid/set_desktop_background_according_to_season][choose my desktop background image according to the
current season]]. -
Files containing an ISO time/date-stamp gets indexed by the
filename-module of [[https://github.com/novoid/Memacs][Memacs]].
-
Alternative implementations of the =filetags= concept:
- [[https://github.com/beutelma/filetags.el][GitHub - DerBeutlin/filetags.el: Emacs package to manage filetags in the filename]]
- With [[https://github.com/protesilaos/denote][denote]], Protesilaos Stavrou implemented a conceptually
related approach to manage notes within an Emacs buffer. With
[[https://en.wikipedia.org/wiki/Dired][Emacs/dired]], this method equally may be applied on files, too.
-
Related to =date2name=:
- https://github.com/DerBeutlin/date2name.el Alternative implementation for [[https://en.wikipedia.org/wiki/Dired][Emacs/dired]]
- https://github.com/muehlburger/d2n Alternative implementation in [[https://go.dev/][Go]]
-
Related to =m2a=:
-
Related to =guessfilename=:
- [[http://www.jonasjberg.com/][Jonas Sjöberg]] took my idea and developed the much more advanced (and
thus a bit more complicated) [[https://github.com/jonasjberg/autonameow][autonameow]]. It uses rule-based renaming,
analyzes content of plain text, epub, pdf and rtf files, extracts
meta-data from many different file formats via [[https://www.sno.phy.queensu.ca/%257Ephil/exiftool/][exiftool]] and so forth. - [[https://www.reddit.com/r/datacurator/comments/f6ku5p/building_an_auto_file_sorter_need_requirements/][This reddit thread]] brought me to [[https://github.com/unreadablewxy/fs-curator][fs-curator]] whose [[https://github.com/unreadablewxy/fs-curator/wiki][documentation]] looks
promising. I did not test it and it's still in an early stage.
However, it could be a future user-friendly part of a workflow that
watches folders for file changes and applies processes like
guessfilename. - I you don't need the full power of a programming language,
[[https://github.com/tfeldmann/organize][organize]] might do the trick for you. Instead of coding Python, you
define your rules within a text file. For many people, this may
seem more user friendly.
- [[http://www.jonasjberg.com/][Jonas Sjöberg]] took my idea and developed the much more advanced (and
-
A research platform for testing file-tagging on all platforms: [[https://karl-voit.at/tagstore/][tagstore]]
- This happens to be an important part of [[https://karl-voit.at/tagstore/downloads/Voit2012b.pdf][my PhD thesis]] in PIM.
- Not maintained since 2013 any more but surely still a cool
starting point in case you want to get a flexible tool when doing
research with tagging interfaces.
-
Good resources for tagging software in general
- [[https://turbofuture.com/computers/Whats-the-Best-Software-for-Tagging-Files-A-Review][What's the Best Software for Tagging Files? | TurboFuture]]
- "Marktübersicht von Tagging-Werkzeugen und Vergleich mit tagstore" (German, 2013): linked on [[https://karl-voit.at/tagstore/en/papers.shtml][this page]] of the [[https://karl-voit.at/tagstore/][tagstore project]]
-
If you do like filetags but you prefer the syntax of [[https://www.tagspaces.org/][TagSpaces]] for
adding tags to file names, you should check out [[https://github.com/jgru/filetags][this filetags fork]].
Maintenance is limited though. Please notice that my other tools
working with tags do not support TagSpaces-style either. -
https://forge.chapril.org/tykayn/rangement.git
- An NPM implementation of a subset of GuessFileName (using image exif header), append2name, move2archive
- You probably need to read a bit of French
--- END SHARED: filetags_tools --- see https://github.com/novoid/screencasts/
- How to Thank Me
--- BEGIN SHARED: how_to_thank_me --- see https://github.com/novoid/screencasts/
I'm glad if you like my tool. I've got way more projects on:
- [[https://github.com/novoid/][GitHub]] (oldest projects),
- [[https://gitlab.com/publicvoit/][GitLab.com]] (older projects), and
- [[https://codeberg.org/publicvoit/][Codeberg]] (newest projects).
If you want to support me:
- [[https://karl-voit.at/2018/06/07/cardware/][Send old-fashioned postcard per snailmail]] - I love personal feedback!
- see [[http://tinyurl.com/j6w8hyo][my address]]
- Send feature wishes or improvements as an issue
- Create issues for bugs
- Contribute merge requests for bug fixes
- Check out my other cool projects on the platforms above
If you want to contribute to this cool project, please fork and
contribute!
I am using [[http://www.python.org/dev/peps/pep-0008/][Python PEP8]] and occasionally some ideas from [[http://en.wikipedia.org/wiki/Test-driven_development][Test Driven
Development (TDD)]]. I fancy Python3 with [[https://typing.python.org/en/latest/spec/annotations.html][type annotations]], although I'm
not using them everywhere at the moment. Starting with 2025, I began
to use help from Claude.ai which is a huge improvement, given my lack
of programming practice and knowledge.
After all, each of my tools was developed because I needed its
functionality and could not get it elsewhere - at least to my
knowledge or taste.
--- END SHARED: how_to_thank_me --- see https://github.com/novoid/screencasts/
- Local Variables :noexport: