date2name


Namedate2name JSON
Version 2024.4.26.1 PyPI version JSON
download
home_pageNone
SummaryHandling time-stamps and date-stamps in file names
upload_time2024-04-26 13:53:57
maintainerNone
docs_urlNone
authorKarl Voit
requires_python<4.0,>=3.9
licenseGPL v3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            * Handling time-stamps and date-stamps in file names

#+BEGIN_HTML
<a href="https://karl-voit.at/demo-date2name">
<img src="https://raw.githubusercontent.com/novoid/screencasts/master/file_management/date2name.gif" />
</a>
#+END_HTML

[[file:bin/screencast.gif]]

Per default, date2name gets the modification time of matching files
and directories and adds a datestamp in standard ISO 8601+ format
YYYY-MM-DD (http://datestamps.org/index.shtml) at the beginning of
the file- or directoryname.

If an existing timestamp is found, its style will be converted to the
selected ISO datestamp format but the numbers stays the same.
Executed with an examplefilename "file" this results e.g. in
"2008-12-31_file".

Note: Other that defined in ISO 8601+ the delimiter between hours,
minutes, and seconds is not a colon but a dot. Colons are causing
several problems on different file systems and are there fore replaced
with the (older) DIN 5008 version with dots.

: Usage:
:          date2name [options] file ...

Run "date2name --help" for usage hints such as:

: Options:
:   -h, --help         show the extended help message and exit
:   -d, --directories  modify only directory names
:   -f, --files        modify only file names
:   -S, --short        use short datestamp               (YYMMDD)
:   -C, --compact      use compact datestamp             (YYYYMMDD)
:   -M, --month        use datestamp with year and month (YYYY-MM)
:   -w, --withtime     use datestamp including seconds   (YYYY-MM-DDThh.mm.ss)
:   -r, --remove       remove all known datestamps
:   -m, --mtime        take modification time for datestamp [default]
:   -c, --ctime        take creation time for datestamp
:   --delimiter        overwrite default delimiter
:   --nocorrections    do not convert existing datestamps to new format
:   -q, --quiet        do not output anything but just errors on console
:   -v, --verbose      enable verbose mode
:   -s, --dryrun       enable dryrun mode: just simulate what would happen, do
:                      not modify files or directories
:   --version          display version and exit

* Installation

First, you need the programming platform [[https://www.python.org/downloads/][Python]] installed.

Then, you can

1. get =date2name= manually from [[https://github.com/novoid/date2name][GitHub]] OR
2. install it via =pip install date2name= which is simplest method.

* Integration Into Common Tools

** Integration into Windows File Explorer

The easiest way to integrate =date2name= into File Explorer ("Send to"
context menu) is by using [[https://github.com/novoid/integratethis][integratethis]].

Execute this in your command line environment:

: pip install date2name integratethis
: integratethis date2name
: integratethis time2name

*** Manual Integration into Windows Explorer for single files

Use this only if the [[https://github.com/novoid/integratethis][integratethis]] method can not be applied:

Create a registry file =add_date2name_to_context_menu.reg= and edit it
to meet the following template. Please make sure to replace the paths
(python, =USERNAME= and =date2name.py=) accordingly:

#+BEGIN_EXAMPLE
Windows Registry Editor Version 5.00

;; for files:

[HKEY_CLASSES_ROOT\*\shell\date2name]
@="date2name (single file)"

[HKEY_CLASSES_ROOT\*\shell\date2name\command]
@="C:\\Python36\\python.exe C:\\Users\\USERNAME\\src\\date2name\\date2name.py -i \"%1\""
#+END_EXAMPLE

Execute the reg-file, confirm the warnings (you are modifying your
Windows registry after all) and cheer up when you notice "date2name
(single file)" in the context menu of your Windows Explorer.

As the heading and the link name suggests: [[https://stackoverflow.com/questions/6440715/how-to-pass-multiple-filenames-to-a-context-menu-shell-command][this method works on single
files]]. So if you select three files and invoke this context menu item,
you will get three different filetag-windows to tag one file each.

** Integration into Thunar

[[https://en.wikipedia.org/wiki/Thunar][Thunar]] is a popular GNU/Linux file browser for the xfce environment.

Unfortunately, it is rather complicated to add custom commands to
Thunar. I found [[https://askubuntu.com/questions/403922/keyboard-shortcut-for-thunar-custom-actions][a good description]] which you might want to follow.

To my disappoinment, even this manual confguration is not stable
somehow. From time to time, the IDs of ~$HOME/.config/Thunar/uca.xml~
and ~$HOME/.config/Thunar/accels.scm~ differ.

For people using Org-mode, I automated the updating process (not the
initial adding process) to match IDs again:

Script for checking "tag": do it ~tag-ID~ and path in ~accels.scm~ match?
: #+BEGIN_SRC sh :var myname="tag"
: ID=`egrep -A 2 "<name>$myname" $HOME/.config/Thunar/uca.xml | grep unique-id | sed 's#.*<unique-id>##' | sed 's#<.*$##'`
: echo "$myname-ID of uca.xml: $ID"
: echo "In accels.scm: "`grep -i "$ID" $HOME/.config/Thunar/accels.scm`
: #+END_SRC

If they don't match, following script re-writes ~accels.scm~ with the current ID:
: #+BEGIN_SRC sh :var myname="tag" :var myshortcut="<Alt>t"
: ID=`egrep -A 2 "<name>$myname" $HOME/.config/Thunar/uca.xml | grep unique-id | sed 's#.*<unique-id>##' | sed 's#<.*$##'`
: echo "appending $myname-ID of uca.xml to accels.scm: $ID"
: mv $HOME/.config/Thunar/accels.scm $HOME/.config/Thunar/accels.scm.OLD
: grep -v "\"$myshortcut\"" $HOME/.config/Thunar/accels.scm.OLD > $HOME/.config/Thunar/accels.scm
: rm $HOME/.config/Thunar/accels.scm.OLD
: echo "(gtk_accel_path \"<Actions>/ThunarActions/uca-action-$ID\" \"$myshortcut\")" >> $HOME/.config/Thunar/accels.scm
: #+END_SRC

** Integration into FreeCommander

[[http://freecommander.com/en/summary/][FreeCommander]] is a [[https://en.wikipedia.org/wiki/File_manager#Orthodox_file_managers][orthodox file manager]] for Windows. You can add
date2name as an favorite command:

- Tools → Favorite tools → Favorite tools edit... (S-C-y)
  - Create new toolbar (if none is present)
  - Icon for "Add new item"
    - Name: date2name
    - Program or folder: <Path to date2name.bar>
	- =date2name.bat= looks like: (please do modify the paths to meet your requirement)
        : C:\Python36\python.exe C:\Users\YOURUSERNAME\src\date2name\date2name %*
	  : REM optionally: set /p DUMMY=Hit ENTER to continue...
    - Start folder: =%ActivDir%=
    - Parameter: =%ActivSel%=
    - [X] Enclose each selected item with ="=
    - Hotkey: select next available one such as =Ctrl-1= (it gets overwritten below)
	- remember its name such as "Favorite tool 01"
  - OK

So far, we've got =date2name= added as a favorite command which can be
accessed via menu or icon toolbar and the selected keyboard shortcut.
If you want to assign a different keyboard shortcut than =Ctrl-1= like
=Alt-d= you might as well follow following procedure:

- Tools → Define keyboard shortcuts...
  - Scroll down to the last section "Favorite tools"
  - locate the name such as "Favorite tool 01"
  - Define your shortcut of choice like =Alt-d= in the right hand side of the window
    - If your shortcut is taken, you'll get a notification. Don't
      overwrite essential shortcuts you're using.
  - OK

* Related tools and workflows

Alternative implementations of date2name:
- https://github.com/DerBeutlin/date2name.el for Emacs/dired
- https://github.com/muehlburger/d2n in Go

---------------

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.

In short:

For *tagging*, please refer to [[https://github.com/novoid/filetags][filetags]] and its documentation.

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]].

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]].

Here is [[https://glt18-programm.linuxtage.at/events/321.html][a 45 minute talk I gave]] at [[https://glt18.linuxtage.at/][Linuxtage Graz 2018]] presenting the
idea of and workflows related to appendfilename and other handy tools
for file management:

[[https://media.ccc.de/v/GLT18_-_321_-_en_-_g_ap147_004_-_201804281550_-_the_advantages_of_file_name_conventions_and_tagging_-_karl_voit/][bin/2018-05-06 filetags demo slide for video preview with video button -- screenshots.png]]

* How to Thank Me

I'm glad you like my tools. If you want to support me:

- 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 on GitHub
- Create issues on GitHub for bugs
- Contribute merge requests for bug fixes
- Check out my other cool [[https://github.com/novoid][projects on GitHub]]

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "date2name",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Karl Voit",
    "author_email": "tools@Karl-Voit.at",
    "download_url": "https://files.pythonhosted.org/packages/43/bb/78a22285b3184634463ecb55c9924f72b33effa433cdb8b0aab6527d5804/date2name-2024.4.26.1.tar.gz",
    "platform": null,
    "description": "* Handling time-stamps and date-stamps in file names\n\n#+BEGIN_HTML\n<a href=\"https://karl-voit.at/demo-date2name\">\n<img src=\"https://raw.githubusercontent.com/novoid/screencasts/master/file_management/date2name.gif\" />\n</a>\n#+END_HTML\n\n[[file:bin/screencast.gif]]\n\nPer default, date2name gets the modification time of matching files\nand directories and adds a datestamp in standard ISO 8601+ format\nYYYY-MM-DD (http://datestamps.org/index.shtml) at the beginning of\nthe file- or directoryname.\n\nIf an existing timestamp is found, its style will be converted to the\nselected ISO datestamp format but the numbers stays the same.\nExecuted with an examplefilename \"file\" this results e.g. in\n\"2008-12-31_file\".\n\nNote: Other that defined in ISO 8601+ the delimiter between hours,\nminutes, and seconds is not a colon but a dot. Colons are causing\nseveral problems on different file systems and are there fore replaced\nwith the (older) DIN 5008 version with dots.\n\n: Usage:\n:          date2name [options] file ...\n\nRun \"date2name --help\" for usage hints such as:\n\n: Options:\n:   -h, --help         show the extended help message and exit\n:   -d, --directories  modify only directory names\n:   -f, --files        modify only file names\n:   -S, --short        use short datestamp               (YYMMDD)\n:   -C, --compact      use compact datestamp             (YYYYMMDD)\n:   -M, --month        use datestamp with year and month (YYYY-MM)\n:   -w, --withtime     use datestamp including seconds   (YYYY-MM-DDThh.mm.ss)\n:   -r, --remove       remove all known datestamps\n:   -m, --mtime        take modification time for datestamp [default]\n:   -c, --ctime        take creation time for datestamp\n:   --delimiter        overwrite default delimiter\n:   --nocorrections    do not convert existing datestamps to new format\n:   -q, --quiet        do not output anything but just errors on console\n:   -v, --verbose      enable verbose mode\n:   -s, --dryrun       enable dryrun mode: just simulate what would happen, do\n:                      not modify files or directories\n:   --version          display version and exit\n\n* Installation\n\nFirst, you need the programming platform [[https://www.python.org/downloads/][Python]] installed.\n\nThen, you can\n\n1. get =date2name= manually from [[https://github.com/novoid/date2name][GitHub]] OR\n2. install it via =pip install date2name= which is simplest method.\n\n* Integration Into Common Tools\n\n** Integration into Windows File Explorer\n\nThe easiest way to integrate =date2name= into File Explorer (\"Send to\"\ncontext menu) is by using [[https://github.com/novoid/integratethis][integratethis]].\n\nExecute this in your command line environment:\n\n: pip install date2name integratethis\n: integratethis date2name\n: integratethis time2name\n\n*** Manual Integration into Windows Explorer for single files\n\nUse this only if the [[https://github.com/novoid/integratethis][integratethis]] method can not be applied:\n\nCreate a registry file =add_date2name_to_context_menu.reg= and edit it\nto meet the following template. Please make sure to replace the paths\n(python, =USERNAME= and =date2name.py=) accordingly:\n\n#+BEGIN_EXAMPLE\nWindows Registry Editor Version 5.00\n\n;; for files:\n\n[HKEY_CLASSES_ROOT\\*\\shell\\date2name]\n@=\"date2name (single file)\"\n\n[HKEY_CLASSES_ROOT\\*\\shell\\date2name\\command]\n@=\"C:\\\\Python36\\\\python.exe C:\\\\Users\\\\USERNAME\\\\src\\\\date2name\\\\date2name.py -i \\\"%1\\\"\"\n#+END_EXAMPLE\n\nExecute the reg-file, confirm the warnings (you are modifying your\nWindows registry after all) and cheer up when you notice \"date2name\n(single file)\" in the context menu of your Windows Explorer.\n\nAs the heading and the link name suggests: [[https://stackoverflow.com/questions/6440715/how-to-pass-multiple-filenames-to-a-context-menu-shell-command][this method works on single\nfiles]]. So if you select three files and invoke this context menu item,\nyou will get three different filetag-windows to tag one file each.\n\n** Integration into Thunar\n\n[[https://en.wikipedia.org/wiki/Thunar][Thunar]] is a popular GNU/Linux file browser for the xfce environment.\n\nUnfortunately, it is rather complicated to add custom commands to\nThunar. I found [[https://askubuntu.com/questions/403922/keyboard-shortcut-for-thunar-custom-actions][a good description]] which you might want to follow.\n\nTo my disappoinment, even this manual confguration is not stable\nsomehow. From time to time, the IDs of ~$HOME/.config/Thunar/uca.xml~\nand ~$HOME/.config/Thunar/accels.scm~ differ.\n\nFor people using Org-mode, I automated the updating process (not the\ninitial adding process) to match IDs again:\n\nScript for checking \"tag\": do it ~tag-ID~ and path in ~accels.scm~ match?\n: #+BEGIN_SRC sh :var myname=\"tag\"\n: ID=`egrep -A 2 \"<name>$myname\" $HOME/.config/Thunar/uca.xml | grep unique-id | sed 's#.*<unique-id>##' | sed 's#<.*$##'`\n: echo \"$myname-ID of uca.xml: $ID\"\n: echo \"In accels.scm: \"`grep -i \"$ID\" $HOME/.config/Thunar/accels.scm`\n: #+END_SRC\n\nIf they don't match, following script re-writes ~accels.scm~ with the current ID:\n: #+BEGIN_SRC sh :var myname=\"tag\" :var myshortcut=\"<Alt>t\"\n: ID=`egrep -A 2 \"<name>$myname\" $HOME/.config/Thunar/uca.xml | grep unique-id | sed 's#.*<unique-id>##' | sed 's#<.*$##'`\n: echo \"appending $myname-ID of uca.xml to accels.scm: $ID\"\n: mv $HOME/.config/Thunar/accels.scm $HOME/.config/Thunar/accels.scm.OLD\n: grep -v \"\\\"$myshortcut\\\"\" $HOME/.config/Thunar/accels.scm.OLD > $HOME/.config/Thunar/accels.scm\n: rm $HOME/.config/Thunar/accels.scm.OLD\n: echo \"(gtk_accel_path \\\"<Actions>/ThunarActions/uca-action-$ID\\\" \\\"$myshortcut\\\")\" >> $HOME/.config/Thunar/accels.scm\n: #+END_SRC\n\n** Integration into FreeCommander\n\n[[http://freecommander.com/en/summary/][FreeCommander]] is a [[https://en.wikipedia.org/wiki/File_manager#Orthodox_file_managers][orthodox file manager]] for Windows. You can add\ndate2name as an favorite command:\n\n- Tools \u2192 Favorite tools \u2192 Favorite tools edit... (S-C-y)\n  - Create new toolbar (if none is present)\n  - Icon for \"Add new item\"\n    - Name: date2name\n    - Program or folder: <Path to date2name.bar>\n\t- =date2name.bat= looks like: (please do modify the paths to meet your requirement)\n        : C:\\Python36\\python.exe C:\\Users\\YOURUSERNAME\\src\\date2name\\date2name %*\n\t  : REM optionally: set /p DUMMY=Hit ENTER to continue...\n    - Start folder: =%ActivDir%=\n    - Parameter: =%ActivSel%=\n    - [X] Enclose each selected item with =\"=\n    - Hotkey: select next available one such as =Ctrl-1= (it gets overwritten below)\n\t- remember its name such as \"Favorite tool 01\"\n  - OK\n\nSo far, we've got =date2name= added as a favorite command which can be\naccessed via menu or icon toolbar and the selected keyboard shortcut.\nIf you want to assign a different keyboard shortcut than =Ctrl-1= like\n=Alt-d= you might as well follow following procedure:\n\n- Tools \u2192 Define keyboard shortcuts...\n  - Scroll down to the last section \"Favorite tools\"\n  - locate the name such as \"Favorite tool 01\"\n  - Define your shortcut of choice like =Alt-d= in the right hand side of the window\n    - If your shortcut is taken, you'll get a notification. Don't\n      overwrite essential shortcuts you're using.\n  - OK\n\n* Related tools and workflows\n\nAlternative implementations of date2name:\n- https://github.com/DerBeutlin/date2name.el for Emacs/dired\n- https://github.com/muehlburger/d2n in Go\n\n---------------\n\nThis tool is part of a tool-set which I use to manage my digital files\nsuch as photographs. My work-flows are described in [[http://karl-voit.at/managing-digital-photographs/][this blog posting]]\nyou might like to read.\n\nIn short:\n\nFor *tagging*, please refer to [[https://github.com/novoid/filetags][filetags]] and its documentation.\n\nSee [[https://github.com/novoid/date2name][date2name]] for easily adding ISO *time-stamps or date-stamps* to\nfiles.\n\nFor *easily naming and tagging* files within file browsers that allow\nintegration of external tools, see [[https://github.com/novoid/appendfilename][appendfilename]] (once more) and\n[[https://github.com/novoid/filetags][filetags]].\n\nMoving to the archive folders is done using [[https://github.com/novoid/move2archive][move2archive]].\n\nHaving tagged photographs gives you many advantages. For example, I\nautomatically [[https://github.com/novoid/set_desktop_background_according_to_season][choose my *desktop background image* according to the\ncurrent season]].\n\nFiles containing an ISO time/date-stamp gets indexed by the\nfilename-module of [[https://github.com/novoid/Memacs][Memacs]].\n\nHere is [[https://glt18-programm.linuxtage.at/events/321.html][a 45 minute talk I gave]] at [[https://glt18.linuxtage.at/][Linuxtage Graz 2018]] presenting the\nidea of and workflows related to appendfilename and other handy tools\nfor file management:\n\n[[https://media.ccc.de/v/GLT18_-_321_-_en_-_g_ap147_004_-_201804281550_-_the_advantages_of_file_name_conventions_and_tagging_-_karl_voit/][bin/2018-05-06 filetags demo slide for video preview with video button -- screenshots.png]]\n\n* How to Thank Me\n\nI'm glad you like my tools. If you want to support me:\n\n- Send old-fashioned *postcard* per snailmail - I love personal feedback!\n  - see [[http://tinyurl.com/j6w8hyo][my address]]\n- Send feature wishes or improvements as an issue on GitHub\n- Create issues on GitHub for bugs\n- Contribute merge requests for bug fixes\n- Check out my other cool [[https://github.com/novoid][projects on GitHub]]\n",
    "bugtrack_url": null,
    "license": "GPL v3",
    "summary": "Handling time-stamps and date-stamps in file names",
    "version": "2024.4.26.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5eca2cf99637a800df3d48156afe9c6817fbc7bc0c2f0dfec9506db805b5b6ca",
                "md5": "fa362848784ab23714a941106bd93d42",
                "sha256": "2a10e63cd6cfe2cfcc224fa10db0d7e97556729e0c6e03bdf4df1ea545f07bc9"
            },
            "downloads": -1,
            "filename": "date2name-2024.4.26.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fa362848784ab23714a941106bd93d42",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 22547,
            "upload_time": "2024-04-26T13:53:55",
            "upload_time_iso_8601": "2024-04-26T13:53:55.724712Z",
            "url": "https://files.pythonhosted.org/packages/5e/ca/2cf99637a800df3d48156afe9c6817fbc7bc0c2f0dfec9506db805b5b6ca/date2name-2024.4.26.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43bb78a22285b3184634463ecb55c9924f72b33effa433cdb8b0aab6527d5804",
                "md5": "2806b15412e3f00d69fec5c53f15bd15",
                "sha256": "b2dd7c8ae01a6f1cf8a5c1f37da6a35e2474a287fbaaeac202f4bfeaf4e0c1e4"
            },
            "downloads": -1,
            "filename": "date2name-2024.4.26.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2806b15412e3f00d69fec5c53f15bd15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 25705,
            "upload_time": "2024-04-26T13:53:57",
            "upload_time_iso_8601": "2024-04-26T13:53:57.066035Z",
            "url": "https://files.pythonhosted.org/packages/43/bb/78a22285b3184634463ecb55c9924f72b33effa433cdb8b0aab6527d5804/date2name-2024.4.26.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-26 13:53:57",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "date2name"
}
        
Elapsed time: 0.56432s