{ "info": { "author": "Mark Blakeney", "author_email": "mark@irsaere.net", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3" ], "description": "## EDIR - Rename and Delete Files and Directories Using Your Editor\n\n[edir](http://github.com/bulletmark/edir) is a command line utility to\nrename and remove filenames and directories using your text editor.\nRun it in the current directory and `edir` will open your editor on a\nlist of files and directories in that directory. Each item in the\ndirectory will appear on its own numbered line. These numbers are how\n`edir` keeps track of what items are changed. Delete lines to remove\nfiles/directories, or edit lines to rename files/directories. You can\nalso switch pairs of numbers to swap files or directories.\n\n## Comparison to Vidir\n\n[edir](http://github.com/bulletmark/edir) unashamedly mimics the\nfunctionality of the [vidir](https://linux.die.net/man/1/vidir) utility\nfrom [moreutils](https://joeyh.name/code/moreutils/) but aims to improve it in\nthe following ways:\n\n1. `vidir` presents file and directories equivalently but `edir` adds a\n trailing slash `/` to visually discriminate directories. E.g. if `afile` and\n `bfile` are files, `adir` and `bdir` are directories, then `vidir`\n presents these in your editor as follows.\n\n ```\n 1\t./a\n 2\t./b\n 3\t./c\n 4\t./d\n ```\n \n But `edir` presents these as:\n \n ```\n 1\t./a\n 2\t./b\n 3\t./c/\n 4\t./d/\n ```\n\n Note the trailing slash is only for presentation in your editor. You\n are not required to ensure it is present after editing. E.g. editing\n line 3 above to `./e` (or even just to `e`) would still rename the\n directory `c` to `e`.\n\n Note also, that both `edir` and `vidir` show the leading `./` on each\n entry so that any leading spaces are clearly seen, and can be edited.\n\n2. `edir` allows you to remove a file/directory by deleting the line, as\n `vidir` does, but you can also remove it by pre-pending a `#` to\n \"comment it out\" or by substituting an entirely blank line.\n\n3. By default, `edir` prints remove and rename messages whereas `vidir`\n prints those only when the `-v/--verbose` switch is added. You can add\n `-q/--quiet` to `edir` to suppress these messages.\n\n4. When `vidir` is run with the `-v/--verbose` switch then it reports\n the renaming of original to intermediate temporary to final files if\n files are swapped etc. That is rather an implementation detail so\n `edir` only reports the original to final renames which is all the\n user really cares about.\n\n5. To remove a large recursive tree you must pipe the directory tree to\n `vidir` and then explicitly remove all children files and directories\n before deleting a parent directory. You can do this also in `edir` of\n course (and arguably it is probably the safest approach) but there\n are times when you really want to let `edir` remove recursively so\n `edir` adds a `-r/--recurse` switch to allow this. BE CAREFUL USING\n THIS!\n\n6. `vidir` always shows all files and directories in a directory,\n including hidden files and directories (i.e. those starting with a\n `.`). Usually a user does not want to be bothered with these so\n `edir` by default does not show them. They can be included by adding\n the `-a/--all` switch.\n\n7. `edir` does not require the user to specify the `-` if something has\n been piped to standard input. E.g. you need only type `find | edir`\n as opposed to `find | edir -`. Note that `vidir` requires the second\n form.\n\n8. `edir` adds options to only show files (`-f/--files`), or to only\n show directories (`-d/--dirs`).\n\n9. `edir` adds an option to ignore symbolic links (`-l/--nolinks`).\n\n10. `edir` shows a message \"No files or directories\" if there is nothing\n to edit, rather than opening an empty file to edit.\n\n11. `edir` filters out any duplicate paths you may inadvertently specify\n on it's command line.\n\n12. `edir` always invokes a consistent duplicate renaming scheme. E.g. if\n you rename `b`, `c`, `d` all to the same pre-existing name `a` then\n `edir` will rename `b` to `a~`, `c` to `a~1`, `d` to `a~2`.\n Depending on order of operations, `vidir` is not always consistent\n about this, E.g. sometimes it creates a `a~1` with no `a~` (this may\n be a bug in `vidir` that nobody has ever bothered to\n report/address?).\n\n13. `edir` creates the temporary editing file with a `.sh` extension so\n your EDITOR may syntax highlight the entries.\n\n14. `edir` provides an environment value to add custom options to the\n invocation of your editor, and/or to set default `edir` command\n arguments. See below.\n\n15. `edir` is very strict about the format of the lines you edit and\n immediately exits with an error message (before changing anything)\n if you format one of the lines incorrectly. All lines in the edited\n list:\n\n 1. Must start with a number, that number must be in range, and that\n number must be unique,\n 2. Must have at least one white space/tab after the number,\n 3. Must have a remaining valid path name.\n 4. Can start with a `#` or be completely blank to be considered the\n same as deleted.\n\n Note the final edited order of lines does not matter, only the first\n number value is used to match the newly edited line to the original\n line so an easy way to swap two file names is just to swap their\n numbers.\n\n16. `edir` always removes and renames files consistently. The sequence of\n operations applied is:\n\n 1. Deleted files are removed and all renamed files and directories\n are renamed to temporaries. The temporaries are made on the same\n file-system as the target.\n \n 2. Empty deleted directories are removed.\n \n 3. Renamed temporary files and directories are renamed to their target name.\n \n 4. Remaining deleted directories are removed.\n \n In simple terms, remember that files are processed before directories\n so you can rename files into a different directory and then delete\n the original directory, all in one edit.\n\n## Installation\n\nArch users can install [edir from the AUR](https://aur.archlinux.org/packages/edir/).\n\nNote python 3.5 or later is required. Note [edir is on\nPyPI](https://pypi.org/project/edir/) so you can `sudo pip install\nedir` or:\n\n```\n$ git clone http://github.com/bulletmark/edir\n$ sudo make install\n```\n\nOptionally, if you are using an odd system and/or want to install this\nmanually then all you need to do is rename `edir.py` as `edir` and make\nit executable somewhere in your path.\n\nEdir runs on pure Python. No 3rd party packages are required.\n\n## Environment Variables\n\n### EDIR_EDIT_COMMAND\n\n`edir` selects your editor from the first environment value found of:\n`$EDIR_EDIT_COMMAND`, `$VISUAL`, `$EDITOR`, then falls back to \"vi\" if\nnone of these are set.\n\nYou can set `EDIR_EDIT_COMMAND` explicitly to an editor + arguments\nstring if you want `edir` to call your editor with specific arguments.\n\n### EDIR_DEFAULT_ARGS\n\nThis allow you to set default starting arguments to `edir`. Type `edir\n-h` to see the arguments supported. E.g. export `EDIR_DEFAULT_ARGS=\"-q\"`\nto make `edir` not print rename and remove actions.\n\n## Examples\n\nEdit all files and directories in the current directory:\n\n```\n edir\n```\n\nEdit all jpeg files in current dir:\n\n```\n edir *.jpg\n```\n\nEdit all files under current directory and subdirectories:\n\n```\n find | edir -f\n```\n\n## Command Line Options\n\n```\nusage: edir [-h] [-a] [-r] [-q] [-f | -d] [-l] [args [args ...]]\n\nProgram to rename and remove files and directories using your editor.\n\npositional arguments:\n args file|dir, or \"-\" for stdin\n\noptional arguments:\n -h, --help show this help message and exit\n -a, --all include/show all (including hidden) files\n -r, --recurse recursively remove any files and directories in removed\n directories that are non-empty\n -q, --quiet do not print rename/remove actions\n -f, --files only show files\n -d, --dirs only show directories\n -l, --nolinks ignore all symlinks\n```\n\n## Embed in Ranger File Manager\n\nIn many ways `edir` (and `vidir`) are better than the\n[ranger](https://ranger.github.io/)\n[bulkrename](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)\ncommand (which does not handle name clashes etc). To add `edir` as a\ncommand within ranger, add or create the following in\n`~/.config/ranger/commands.py`\n\n```python\nfrom ranger.api.commands import Command\n\nclass edir(Command):\n '''\n :edir [file|dir]\n\n Run edir on the selected file or dir.\n Default argument is current dir.\n '''\n def execute(self):\n self.fm.run('edir -q ' + self.rest(1))\n def tab(self, tabnum):\n return self._tab_directory_content()\n```\n\n## License\n\nCopyright (C) 2019 Mark Blakeney. This program is distributed under the\nterms of the GNU General Public License.\nThis program is free software: you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the\nFree Software Foundation, either version 3 of the License, or any later\nversion.\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General\nPublic License at for more details.\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bulletmark/edir", "keywords": "vidir", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "edir", "package_url": "https://pypi.org/project/edir/", "platform": "", "project_url": "https://pypi.org/project/edir/", "project_urls": { "Homepage": "https://github.com/bulletmark/edir" }, "release_url": "https://pypi.org/project/edir/1.3/", "requires_dist": null, "requires_python": ">=3.5", "summary": "Utility to rename and remove files/dirs using your editor", "version": "1.3" }, "last_serial": 5685505, "releases": { "1.3": [ { "comment_text": "", "digests": { "md5": "c8ae8aafa44b04f5b499039a12c08a07", "sha256": "d6496d44493adb84679d4fc8fdd963a43c9781928ba859240dd2ee105f8f0be3" }, "downloads": -1, "filename": "edir-1.3.tar.gz", "has_sig": false, "md5_digest": "c8ae8aafa44b04f5b499039a12c08a07", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 8890, "upload_time": "2019-08-16T03:43:44", "url": "https://files.pythonhosted.org/packages/c6/f2/d75dd069c5d5f85dc3d5be7e03437265d5139ff50ebbf021198e7a62dcb3/edir-1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c8ae8aafa44b04f5b499039a12c08a07", "sha256": "d6496d44493adb84679d4fc8fdd963a43c9781928ba859240dd2ee105f8f0be3" }, "downloads": -1, "filename": "edir-1.3.tar.gz", "has_sig": false, "md5_digest": "c8ae8aafa44b04f5b499039a12c08a07", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 8890, "upload_time": "2019-08-16T03:43:44", "url": "https://files.pythonhosted.org/packages/c6/f2/d75dd069c5d5f85dc3d5be7e03437265d5139ff50ebbf021198e7a62dcb3/edir-1.3.tar.gz" } ] }