# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['appendfilename']

package_data = \
{'': ['*']}

install_requires = \
['pyreadline3']

entry_points = \
{'console_scripts': ['appendfilename = appendfilename:main']}

setup_kwargs = {
    'name': 'appendfilename',
    'version': '2025.5.14',
    'description': 'Intelligent appending text to file names, considering file extensions and file tags',
    'long_description': '# appendfilename.py\n\n<a href="https://karl-voit.at/demo-appendfilename">\n<img src="https://raw.githubusercontent.com/novoid/screencasts/master/file_management/appendfilename.gif" />\n</a>\n\n![](bin/screencast.gif)\n\nThis Python script adds a string to a file name. The string gets added\nbetween the original file name and its extension.\n\nIn case the file name contains tags as handled as with\n[filetag](https://github.com/novoid/filetag), the string gets added\nright before the separator between file name and tags.\n\nExamples for adding the string "new text":\n\n| **old file name** | **new file name** |\n|----|----|\n| a simple file.txt | a simple file new text.txt |\n| a simple file – foo bar.txt | a simple file new text – foo bar.txt |\n| 2013-05-09.jpeg | 2013-05-09 new text.jpeg |\n| 2013-05-09T16.17.jpeg | 2013-05-09T16.17 new text.jpeg |\n| 2013-05-09T16.17_img_00042.jpeg | 2013-05-09T16.17_img_00042 new text.jpeg |\n| 2013-05-09T16.17_img_00042 – fun.jpeg | 2013-05-09T16.17_img_00042 new text – fun.jpeg |\n\n- **Target group**: users who are able to use command line tools and who\n  are using tags in file names.\n- Hosted on github: <https://github.com/novoid/appendfilename>\n\n## Why\n\nBesides the fact that I am using [ISO dates and\ntimes](https://en.wikipedia.org/wiki/Iso_date) in file names (as shown\nin examples above), I am using tags with file names. To separate tags\nfrom the file name, I am using the four separator characters: space dash\ndash space.\n\nFor people familiar with [Regular\nExpressions](https://en.wikipedia.org/wiki/Regex):\n\n``` example\n(<ISO date/time stamp>)? <descriptive file name> -- <list of tags separated by spaces>.extension\n```\n\nFor tagging, please refer to\n[filetag](https://github.com/novoid/filetag) and its documentation.\n\nIf I want to add a descriptive file name to files like , e.g. ,\nphotographs, I have to rename the original file and insert the\ndescription at the right spot of the existing file name.\n\nThis is an error-prone task. If I am not careful, I can overwrite parts\nof the old file name I wanted to keep. Or I could mess up spacing\nbetween the old file name, tags, and the new description.\n\nTherefore, I wrote this script that adds a description to the file name\nwithout removing old file name parts or tags.\n\nYou may like to add this tool to your image or file manager of choice. I\nadded mine to [geeqie](http://geeqie.sourceforge.net/) which is my\nfavorite image viewer on GNU/Linux.\n\n## Usage\n\n``` example\nappendfilename --text foo a_file_name.txt\n```\n\n… adds "foo" such that it results in `a_file_name foo.txt`\n\n``` example\nappendfilename a_file_name.txt\n```\n\n… (implicit) interactive mode: asking for the string to add from the\nuser\n\n``` example\nappendfilename --text "foo bar" "file name 1.jpg" "file name 2 -- foo.txt" "file name 3 -- bar.csv"\n```\n\n… adds tag "foo" such that it results in …\n\n``` example\n"file name 1 foo bar.jpg"\n"file name 2 foo bar -- foo.txt"\n"file name 3 foo bar -- bar.csv"\n```\n\nFor a complete list of parameters, please try:\n\n``` example\nappendfilename --help\n```\n\nThe file names within the current working directory is read in and all\nfound words can be completed via TAB.\n\n------------------------------------------------------------------------\n\n``` bash\n./appendfilename/__init__.py --help\n```\n\n    Usage:\n        appendfilename [<options>] <list of files>\n\n    This tool inserts text between the old file name and optional tags or file extension.\n\n\n    Text within file names is placed between the actual file name and\n    the file extension or (if found) between the actual file namd and\n    a set of tags separated with " -- ".\n      Update for the Boss  <NEW TEXT HERE>.pptx\n      2013-05-16T15.31.42 Error message <NEW TEXT HERE> -- screenshot projectB.png\n\n    When renaming a symbolic link whose source file has a matching file\n    name, the source file gets renamed as well.\n\n    Example usages:\n      appendfilename --text="of projectA" "the presentation.pptx"\n          ... results in "the presentation of projectA.pptx"\n      appendfilename "2013-05-09T16.17_img_00042 -- fun.jpeg"\n          ... with interactive input of "Peter" results in:\n              "2013-05-09T16.17_img_00042 Peter -- fun.jpeg"\n\n\n    :copyright: (c) 2013 or later by Karl Voit <tools@Karl-Voit.at>\n    :license: GPL v3 or any later version\n    :URL: https://github.com/novoid/appendfilename\n    :bugreports: via github or <tools@Karl-Voit.at>\n    :version: 2019-10-19\n\n\n    Options:\n      -h, --help            show this help message and exit\n      -t TEXT, --text=TEXT  the text to add to the file name\n      -p, --prepend         Do the opposite: instead of appending the text,\n                            prepend the text\n      --smart-prepend       Like "--prepend" but do respect date/time-stamps:\n                            insert new text between "YYYY-MM-DD(Thh.mm(.ss))" and\n                            rest\n      -s, --dryrun          enable dryrun mode: just simulate what would happen,\n                            do not modify file(s)\n      -v, --verbose         enable verbose mode\n      -q, --quiet           enable quiet mode\n      --version             display version and exit\n\n## Installation\n\nGet it from [PyPI](https://pypi.org/project/appendfilename/\\\\) by the\ncommand `pip install appendfilename`. If you clone or fetch it from\n[GitHub](https://github.com/novoid/appendfilename), enter the folder of\nyour copy and resolve the dependencies defined in `pyproject.toml` by\neither\n\n``` bash\npip install .\npip install .[dev]\n```\n\nfor use, or development. In the later case, don\'t forget the optional\n`-e` flag to render the installation editable.\n\n## Smart Prepend\n\nAlthough `appendfilename` was created mainly to *add text at the end of\na file name*, it may also insert text at the beginning of a file name\nusing the `--prepend` parameter.\n\nA variance of that is `--smart-prepend`. Following examples demonstrate\nthe effects on smart prepending "new text" with various file names:\n\n``` example\nnew text foo bar.txt\n2019-10-20 new text foo bar.txt\n2019-10-20T12.34 new text foo bar.txt\n2019-10-20T12.34.56 new text foo bar.txt\n```\n\nAs you can see, `--smart-prepend` does take into account that a given\ndate/time-stamp according to\n[date2name](https://github.com/novoid/date2name) and [this\narticle](https://karl-voit.at/managing-digital-photographs/) will always\nstay the first part of a file name, prepending the "new text" between\nthe date/time-stamp and the rest.\n\n# Integration Into Common Tools\n\n## Integration into Windows File Explorer\n\nThe easiest way to integrate `appendfilename` into File Explorer ("Send\nto" context menu) is by using\n[integratethis](https://github.com/novoid/integratethis).\n\nExecute this in your command line environment:\n\n``` example\npip install appendfilename integratethis\nintegratethis appendfilename --confirm\n```\n\n### Windows File Explorer for single files (manual method)\n\nUse this only if the\n[integratethis](https://github.com/novoid/integratethis) method can not\nbe applied:\n\nCreate a registry file `add_appendfilename_to_context_menu.reg` and edit\nit to meet the following template. Please make sure to replace the paths\n(python, `USERNAME` and `appendfilename`) accordingly:\n\n``` example\nWindows Registry Editor Version 5.00\n\n;; for files:\n\n[HKEY_CLASSES_ROOT\\*\\shell\\appendfilename]\n@="appendfilename (single file)"\n\n[HKEY_CLASSES_ROOT\\*\\shell\\appendfilename\\command]\n@="C:\\\\Python36\\\\python.exe C:\\\\Users\\\\USERNAME\\\\src\\\\appendfilename\\\\appendfilename\\\\__init__.py -i \\"%1\\""\n```\n\nExecute the reg-file, confirm the warnings (you are modifying your\nWindows registry after all) and cheer up when you notice "appendfilename\n(single file)" in the context menu of your Windows Explorer.\n\nAs the heading and the link name suggests: [this method works on single\nfiles](https://stackoverflow.com/questions/6440715/how-to-pass-multiple-filenames-to-a-context-menu-shell-command).\nSo if you select three files and invoke this context menu item, you will\nget three different filetag-windows to tag one file each.\n\n### Windows File Explorer for single and multiple selected files (manual method)\n\nUse this only if the\n[integratethis](https://github.com/novoid/integratethis) method can not\nbe applied:\n\nCreate a batch file in your home directory. Adapt the paths to meet your\nsetup. The content looks like:\n\n``` example\nC:\\Python36\\python.exe C:\\Users\\USERNAME\\src\\appendfilename\\appendfilename\\__init__.py -i %*\n```\n\nIf you want to confirm the process (and see error messages and so\nforth), you might want to append as well following line:\n\n``` example\nset /p DUMMY=Hit ENTER to continue ...\n```\n\nMy batch file is located in `C:\\Users\\USERNAME\\bin\\appendfilename.bat`.\nNow create a lnk file for it (e.g., via Ctrl-Shift-drag), rename the lnk\nfile to `appendfilename.lnk` and move the lnk file to\n`~/AppData/Roaming/Microsoft/Windows/SendTo/`.\n\nThis way, you get a nice entry in your context menu sub-menu "Send to"\nwhich is also correctly tagging selection of files as if you put the\nlist of selected items to a single call of appendfilename.\n\n## Integrating into Geeqie\n\nI am using [geeqie](http://geeqie.sourceforge.net/) for\nbrowsing/presenting image files. After I mark a set of images for adding\nfile name descriptions, I just have to press `a` and I get asked for the\ninput string. After entering the string and RETURN, the filenames are\nmodified accordingly.\n\nUsing GNU/Linux, this is quite easy accomplished. The only thing that is\nnot straight forward is the need for a wrapper script. The wrapper\nscript does provide a shell window for entering the tags.\n\n`vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh` looks\nlike:\n\n``` bash\n#!/bin/sh\n\n/usr/bin/gnome-terminal \\\n    --geometry=73x5+330+5  \\\n    --hide-menubar \\\n    -x /home/vk/src/appendfilename/appendfilename/__init__.py "${@}"\n\n#end\n```\n\nIn `$HOME/.config/geeqie/applications` I wrote two desktop files such\nthat geeqie shows the wrapper scripts as external editors to its image\nfiles:\n\n`$HOME/.config/geeqie/applications/add-tags.desktop` looks like:\n\n``` example\n[Desktop Entry]\nName=appendfilename\nGenericName=appendfilename\nComment=\nExec=/home/vk/src/misc/vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh %F\nIcon=\nTerminal=true\nType=Application\nCategories=Application;Graphics;\nhidden=false\nMimeType=image/*;video/*;image/mpo;image/thm\nCategories=X-Geeqie;\n```\n\nIn order to be able to use the keyboard shortcuts `a`, you can define\nthem in geeqie:\n\n1.  Edit \\> Preferences \\> Preferences … \\> Keyboard.\n2.  Scroll to the bottom of the list.\n3.  Double click in the `KEY`-column of `appendfilename` and choose your\n    desired keyboard shortcut accordingly.\n\nI hope this method is as handy for you as it is for me :-)\n\n## Integration into Thunar\n\n[Thunar](https://en.wikipedia.org/wiki/Thunar) is a popular GNU/Linux\nfile browser for the xfce environment.\n\nUnfortunately, it is rather complicated to add custom commands to\nThunar. I found [a good\ndescription](https://askubuntu.com/questions/403922/keyboard-shortcut-for-thunar-custom-actions)\nwhich 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`\nmatch?\n\n``` example\n#+BEGIN_SRC sh :var myname="tag"\nID=`egrep -A 2 "<name>$myname" $HOME/.config/Thunar/uca.xml | grep unique-id | sed \'s#.*<unique-id>##\' | sed \'s#<.*$##\'`\necho "$myname-ID of uca.xml: $ID"\necho "In accels.scm: "`grep -i "$ID" $HOME/.config/Thunar/accels.scm`\n#+END_SRC\n```\n\nIf they don\'t match, following script re-writes `accels.scm` with the\ncurrent ID:\n\n``` example\n#+BEGIN_SRC sh :var myname="tag" :var myshortcut="<Alt>t"\nID=`egrep -A 2 "<name>$myname" $HOME/.config/Thunar/uca.xml | grep unique-id | sed \'s#.*<unique-id>##\' | sed \'s#<.*$##\'`\necho "appending $myname-ID of uca.xml to accels.scm: $ID"\nmv $HOME/.config/Thunar/accels.scm $HOME/.config/Thunar/accels.scm.OLD\ngrep -v "\\"$myshortcut\\"" $HOME/.config/Thunar/accels.scm.OLD > $HOME/.config/Thunar/accels.scm\nrm $HOME/.config/Thunar/accels.scm.OLD\necho "(gtk_accel_path \\"<Actions>/ThunarActions/uca-action-$ID\\" \\"$myshortcut\\")" >> $HOME/.config/Thunar/accels.scm\n#+END_SRC\n```\n\n## Integration into FreeCommander\n\n[FreeCommander](http://freecommander.com/en/summary/) is a [orthodox\nfile\nmanager](https://en.wikipedia.org/wiki/File_manager#Orthodox_file_managers)\nfor Windows. You can add appendfilename as an favorite command:\n\n- Tools → Favorite tools → Favorite tools edit… (S-C-y)\n\n  - Create new toolbar (if none is present)\n  - Icon for "Add new item"\n    - Name: appendfilename\n    - Program or folder: \\<Path to appendfilename.bar\\>\n\n- `appendfilename.bat` looks like: (please do modify the paths to meet\n  your requirement)\n\n  ``` example\n  C:\\Python36\\python.exe C:\\Users\\YOURUSERNAME\\src\\appendfilename\\appendfilename\\__init__.py %*\n  ```\n\n``` example\nREM optionally: set /p DUMMY=Hit ENTER to continue...\n```\n\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\n  overwritten below)\n\n<!-- -->\n\n- remember its name such as "Favorite tool 01"\n  - OK\n\nSo far, we\'ve got `appendfilename` added as a favorite command which can\nbe accessed 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-a` you might as well follow following procedure:\n\n- Tools → 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-a` in the right hand side\n    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\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 [this blog\nposting](http://karl-voit.at/managing-digital-photographs/) you might\nlike to read.\n\nIn short:\n\nFor **tagging**, please refer to\n[filetags](https://github.com/novoid/filetags) and its documentation.\n\nSee [date2name](https://github.com/novoid/date2name) for easily adding\nISO **time-stamps or date-stamps** to files.\n\nFor **easily naming and tagging** files within file browsers that allow\nintegration of external tools, see\n[appendfilename](https://github.com/novoid/appendfilename) (once more)\nand [filetags](https://github.com/novoid/filetags).\n\nMoving to the archive folders is done using\n[move2archive](https://github.com/novoid/move2archive).\n\nHaving tagged photographs gives you many advantages. For example, I\nautomatically [choose my **desktop background image** according to the\ncurrent\nseason](https://github.com/novoid/set_desktop_background_according_to_season).\n\nFiles containing an ISO time/date-stamp gets indexed by the\nfilename-module of [Memacs](https://github.com/novoid/Memacs).\n\nHere is [a 45 minute talk I\ngave](https://glt18-programm.linuxtage.at/events/321.html) at [Linuxtage\nGraz 2018](https://glt18.linuxtage.at/) presenting the idea of and\nworkflows related to appendfilename and other handy tools for file\nmanagement:\n\n[bin/2018-05-06 filetags demo slide for video preview with video button\n–\nscreenshots.png](https://media.ccc.de/v/GLT18_-_321_-_en_-_g_ap147_004_-_201804281550_-_the_advantages_of_file_name_conventions_and_tagging_-_karl_voit/)\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\n  feedback!\n  - see [my address](http://tinyurl.com/j6w8hyo)\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 [projects on\n  GitHub](https://github.com/novoid)\n',
    'author': 'Karl Voit',
    'author_email': 'tools@Karl-Voit.at',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'None',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.9',
}


setup(**setup_kwargs)
