{"id":17059191,"url":"https://github.com/novoid/appendfilename","last_synced_at":"2025-04-06T14:10:46.324Z","repository":{"id":8501314,"uuid":"10110432","full_name":"novoid/appendfilename","owner":"novoid","description":"Intelligent appending text to file names, considering file extensions and file tags","archived":false,"fork":false,"pushed_at":"2024-11-22T10:30:04.000Z","size":776,"stargazers_count":54,"open_issues_count":6,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T13:09:01.716Z","etag":null,"topics":["files","filesystem","personal-information-management","pim","shell"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/novoid.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-05-16T21:00:08.000Z","updated_at":"2025-03-23T19:29:40.000Z","dependencies_parsed_at":"2024-11-22T11:33:11.219Z","dependency_job_id":null,"html_url":"https://github.com/novoid/appendfilename","commit_stats":{"total_commits":55,"total_committers":3,"mean_commits":"18.333333333333332","dds":"0.12727272727272732","last_synced_commit":"c04aee6c5e8a6e15d993eb90aaa080b0326f9c99"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novoid%2Fappendfilename","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novoid%2Fappendfilename/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novoid%2Fappendfilename/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novoid%2Fappendfilename/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/novoid","download_url":"https://codeload.github.com/novoid/appendfilename/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247492513,"owners_count":20947544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["files","filesystem","personal-information-management","pim","shell"],"created_at":"2024-10-14T10:33:06.690Z","updated_at":"2025-04-06T14:10:46.301Z","avatar_url":"https://github.com/novoid.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"* appendfilename.py\n\n#+BEGIN_HTML\n\u003ca href=\"https://karl-voit.at/demo-appendfilename\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/novoid/screencasts/master/file_management/appendfilename.gif\" /\u003e\n\u003c/a\u003e\n#+END_HTML\n\n[[file: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 [[https://github.com/novoid/filetag][filetag]], the\nstring gets added right before the separator between file name and\ntags.\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 [[https://en.wikipedia.org/wiki/Iso_date][ISO dates and times]] in file names (as\nshown in examples above), I am using tags with file names. To separate\ntags from the file name, I am using the four separator characters:\nspace dash dash space.\n\nFor people familiar with [[https://en.wikipedia.org/wiki/Regex][Regular Expressions]]:\n\n: (\u003cISO date/time stamp\u003e)? \u003cdescriptive file name\u003e -- \u003clist of tags separated by spaces\u003e.extension\n\nFor tagging, please refer to [[https://github.com/novoid/filetag][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\nparts of the old file name I wanted to keep. Or I could mess up\nspacing between the old file name, tags, and the new description.\n\nTherefore, I wrote this script that adds a description to the file\nname without removing old file name parts or tags.\n\nYou may like to add this tool to your image or file manager of\nchoice. I added mine to [[http://geeqie.sourceforge.net/][geeqie]] which is my favorite image viewer on\nGNU/Linux.\n\n** Usage\n\n: appendfilename --text foo a_file_name.txt\n... adds \"foo\" such that it results in ~a_file_name foo.txt~\n\n: appendfilename a_file_name.txt\n... (implicit) interactive mode: asking for the string to add from the user\n\n: appendfilename --text \"foo bar\" \"file name 1.jpg\" \"file name 2 -- foo.txt\" \"file name 3 -- bar.csv\"\n... adds tag \"foo\" such that it results in ...\n: \"file name 1 foo bar.jpg\"\n: \"file name 2 foo bar -- foo.txt\"\n: \"file name 3 foo bar -- bar.csv\"\n\nFor a complete list of parameters, please try:\n: appendfilename --help\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#+BEGIN_SRC sh :results output :wrap src\n./appendfilename/__init__.py --help\n#+END_SRC\n\n#+BEGIN_src\nUsage:\n    appendfilename [\u003coptions\u003e] \u003clist of files\u003e\n\nThis tool inserts text between the old file name and optional tags or file extension.\n\n\nText within file names is placed between the actual file name and\nthe file extension or (if found) between the actual file namd and\na set of tags separated with \" -- \".\n  Update for the Boss  \u003cNEW TEXT HERE\u003e.pptx\n  2013-05-16T15.31.42 Error message \u003cNEW TEXT HERE\u003e -- screenshot projectB.png\n\nWhen renaming a symbolic link whose source file has a matching file\nname, the source file gets renamed as well.\n\nExample 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 \u003ctools@Karl-Voit.at\u003e\n:license: GPL v3 or any later version\n:URL: https://github.com/novoid/appendfilename\n:bugreports: via github or \u003ctools@Karl-Voit.at\u003e\n:version: 2019-10-19\n\n\nOptions:\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#+END_src\n\n** Installation\n\nGet it from [[https://github.com/novoid/appendfilename][GitHub]] or install it via =pip install appendfilename=\n\n** Smart Prepend\n\nAlthough =appendfilename= was created mainly to /add text at the end\nof a file name/, it may also insert text at the beginning of a file\nname using the =--prepend= parameter.\n\nA variance of that is =--smart-prepend=. Following examples\ndemonstrate the effects on smart prepending \"new text\" with various\nfile names:\n\n: new text foo bar.txt\n: 2019-10-20 new text foo bar.txt\n: 2019-10-20T12.34 new text foo bar.txt\n: 2019-10-20T12.34.56 new text foo bar.txt\n\nAs you can see, =--smart-prepend= does take into account that a given\ndate/time-stamp according to [[https://github.com/novoid/date2name][date2name]] and [[https://karl-voit.at/managing-digital-photographs/][this article]] will always\nstay the first part of a file name, prepending the \"new text\" between\nthe date/time-stamp and the rest.\n\n\n* Integration Into Common Tools\n\n** Integration into Windows File Explorer\n\nThe easiest way to integrate =appendfilename= into File Explorer\n(\"Send to\" context menu) is by using [[https://github.com/novoid/integratethis][integratethis]].\n\nExecute this in your command line environment:\n\n: pip install appendfilename integratethis\n: integratethis appendfilename --confirm\n\n*** Windows File Explorer for single files (manual method)\n\nUse this only if the [[https://github.com/novoid/integratethis][integratethis]] method can not be applied:\n\nCreate a registry file =add_appendfilename_to_context_menu.reg= and edit it\nto meet the following template. Please make sure to replace the paths\n(python, =USERNAME= and =appendfilename=) accordingly:\n\n#+BEGIN_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#+END_EXAMPLE\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: [[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*** Windows File Explorer for single and multiple selected files (manual method)\n\nUse this only if the [[https://github.com/novoid/integratethis][integratethis]] method can not be applied:\n\nCreate a batch file in your home directory. Adapt the paths to meet\nyour setup. The content looks like:\n\n: C:\\Python36\\python.exe C:\\Users\\USERNAME\\src\\appendfilename\\appendfilename\\__init__.py -i %*\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: set /p DUMMY=Hit ENTER to continue ...\n\nMy batch file is located in =C:\\Users\\USERNAME\\bin\\appendfilename.bat=. Now\ncreate 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\n** Integrating into Geeqie\n\nI am using [[http://geeqie.sourceforge.net/][geeqie]] for browsing/presenting image files. After I\nmark a set of images for adding file name descriptions, I just have to\npress ~a~ and I get asked for the input string. After entering the string and\nRETURN, the filenames are modified accordingly.\n\nUsing GNU/Linux, this is quite easy accomplished. The only thing that\nis not 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 like:\n\n#+BEGIN_SRC sh\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#+END_SRC\n\nIn ~$HOME/.config/geeqie/applications~ I wrote two desktop files such\nthat geeqie shows the wrapper scripts as external editors to its\nimage files:\n\n~$HOME/.config/geeqie/applications/add-tags.desktop~ looks like:\n: [Desktop Entry]\n: Name=appendfilename\n: GenericName=appendfilename\n: Comment=\n: Exec=/home/vk/src/misc/vk-appendfilename-interactive-wrapper-with-gnome-terminal.sh %F\n: Icon=\n: Terminal=true\n: Type=Application\n: Categories=Application;Graphics;\n: hidden=false\n: MimeType=image/*;video/*;image/mpo;image/thm\n: Categories=X-Geeqie;\n\nIn order to be able to use the keyboard shortcuts ~a~, you can define them in geeqie:\n1. Edit \u003e Preferences \u003e Preferences ... \u003e Keyboard.\n2. Scroll to the bottom of the list.\n3. Double click in the ~KEY~-column of ~appendfilename~\n   and choose your 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[[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 \"\u003cname\u003e$myname\" $HOME/.config/Thunar/uca.xml | grep unique-id | sed 's#.*\u003cunique-id\u003e##' | sed 's#\u003c.*$##'`\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=\"\u003cAlt\u003et\"\n: ID=`egrep -A 2 \"\u003cname\u003e$myname\" $HOME/.config/Thunar/uca.xml | grep unique-id | sed 's#.*\u003cunique-id\u003e##' | sed 's#\u003c.*$##'`\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 \u003e $HOME/.config/Thunar/accels.scm\n: rm $HOME/.config/Thunar/accels.scm.OLD\n: echo \"(gtk_accel_path \\\"\u003cActions\u003e/ThunarActions/uca-action-$ID\\\" \\\"$myshortcut\\\")\" \u003e\u003e $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\nappendfilename as an favorite command:\n\n- Tools → Favorite tools → Favorite tools edit... (S-C-y)\n  - Create new toolbar (if none is present)\n  - Icon for \"Add new item\"\n    - Name: appendfilename\n    - Program or folder: \u003cPath to appendfilename.bar\u003e\n\t- =appendfilename.bat= looks like: (please do modify the paths to meet your requirement)\n        : C:\\Python36\\python.exe C:\\Users\\YOURUSERNAME\\src\\appendfilename\\appendfilename\\__init__.py %*\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 =appendfilename= 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-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 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\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 [[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\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovoid%2Fappendfilename","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovoid%2Fappendfilename","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovoid%2Fappendfilename/lists"}