{ "info": { "author": "\u00c5\u0081ukasz Langa", "author_email": "lukasz@langa.pl", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: GNU General Public License (GPL)", "Natural Language :: English", "Operating System :: POSIX", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "------\nrename\n------\n\nRenames files using regular expression matching. This enables elegant handling\nof multiple renames using a single command.\n\nUsage\n=====\n\nBasic syntax::\n\n rename [-I] [-l] [-q] [-t] [-u] [-v \"except_regex\"] \"regex\" \"target\"\n\n rename -s [-I] [-l] [-q] [-t] [-u] [-v \"except_regex\"] \"substring_from\" \"substring_to\" \"regex\"\n \n rename --selftest [directory]\n\nOptions\n=======\n\nregex\n~~~~~\nRegular expression that matches source files which are to be renamed. Examples::\n\n \"(\\w+).caf\"\n \"IMG(\\d\\d\\d\\d\\).[Jj][Pp][Ee]?[Gg]\"\n \"([0-9]{2})-([0-9]{2})-([12][0-9]{3}).log\"\n\nThe regular expression is **global** by default (e.g. writing ``\"[0-9]\"`` means\n``\"^[0-9]$\"``). This is to avoid accidental partial catches. If you want to\nmatch all files that start or end with a specific expression, add ``.*`` to the\nexpression, e.g. ``\".*\\.mp3\"`` will match all files that end with ``.mp3``.\nWhile that may seem a bit redundant, it's on par with *\"explicit is better than\ninplicit\"* (see `The Zen of Python\n`_). See also: ``-I``.\n\n**Note:** the regex is case-sensitive, also on case-preserving filesystems. If\nyou wish to change that, use the ``-I`` option.\n\ntarget\n~~~~~~\nName of the target file with references to regular expression groups caught in\nthe source matches. References to groups are formed by a backslash character\nfollowed by he group number. Groups are indexed from 1. The group number can be\ncontained within parentheses to disambiguate a reference followed by digits.\nExamples::\n\n \"\\1.aiff\"\n \"\\(1)1337.zip\"\n \"\\3-\\1-\\2.log\"\n\nAutomatic numbering can be introduced using a special ``\\(index)`` reference.\nFor example::\n\n rename \"IMG.*\\.JPG\" \"Judy's Birthday \\(index).jpg\"\n\nBy default indexing starts with 1, increments with 1 and pads numbers with\nenough leading zeroes so that each filename uses the same amount of digits.\nThis can be changed with the ``--index-first``, ``--index-step``,\n``--index-digits`` and ``--index-pad-with`` options.\n\nsubstring_from, substring_to\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWhen using the \"simple\" mode (``-s``), these arguments provide the traditional\nsearch/replace pattern:\n\n * ``substring_from`` is a simple (raw) substring that should be found within\n the filename\n\n * ``substring_to`` is the replacement string\n\nBoth of these strings are raw, e.g. they don't allow for any wildcards, regular\nexpressions and whatnot. This is more-less compatible with behaviour of the\nexisting ``rename`` tool from the ``util-linux-ng`` package. One obvious\ndifference is that the file mask doesn't use wildcards but regular expressions.\n\nExample (translating underscores to spaces)::\n\n rename -s \"_\" \" \" \".*\\.txt\" \n\n**Note:** ``substring_from`` is case-sensitive, also on case-preserving\nfilesystems. If you wish to change that, use the ``-I`` option.\n``substring_to`` is always case-sensitive.\n\n-I, or --case-insensitive\n~~~~~~~~~~~~~~~~~~~~~~~~~\nWhen used, regexes work in a case-insensitive manner, e.g. ``\"lib\"`` will behave\nlike ``\"[Ll][Ii][Bb]\"``. Group references still hold the original case.\n\n-l, or --lower\n~~~~~~~~~~~~~~\nWhen used, renamed filenames are transformed to lower-case. This does not affect\nthe source regex used (i.e. it still matches in a case-sensitive manner, unless\n``-I`` is used). See also: ``-U``.\n\n-q, or --quiet\n~~~~~~~~~~~~~~\nWhen used, no error output is given. The status of invocation should be\ndetermined via the return code.\n\n-s, or --simple\n~~~~~~~~~~~~~~~\n\nInvokes the \"simple\" mode. See: ``substring_from``, ``substring_to``.\n\n-t, or --test\n~~~~~~~~~~~~~\nWhen used, the script will only fake renaming and verbosely state what it would\ndo. Use this if you're unsure of the effects your expression may cause. \n\n-U, or --upper\n~~~~~~~~~~~~~~\nWhen used, renamed filenames are transformed to upper-case. This does not affect\nthe source regex used (i.e. it still matches in a case-sensitive manner, unless\n``-I`` is used). See also: ``-l``.\n\n-v \"except_regex\", or --except \"except_regex\"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nWhen used, any filename matched by the original source regex will be also\nmatched against the ``except_regex``. In case there is a match, the filename is\nskipped. In other words, filenames that match ``except_regex`` will **not** be\nrenamed.\n\nThe regular expression is **local** (e.g. writing ``\"[0-3]\"`` means \"number\n0-3 anywhere in the filename). This is to make the tool err on the side of\ncaution by protecting from renaming too many files by accident when the user\nforgets to add dot-asterisk to ``-v``. If you want to only match whole\nfilenames, use the canonical global form (e.g. ``\"^filename$\"``).\nSee also: ``-I``.\n\n--index-first\n~~~~~~~~~~~~~\nWhen using the special ``\\(index)`` reference, this option specifies what number\nwill the first index be. Default: ``--index-first=1``.\n\n--index-step\n~~~~~~~~~~~~\nWhen using the special ``\\(index)`` reference, this option specifies what number\nwill be added with each step to the first value. The specified number can be\nnegative. Default: ``--index-step=1``.\n\n--index-digits\n~~~~~~~~~~~~~~\nWhen using the special ``\\(index)`` reference, this option specifies how many\ndigits will be used in each reference. If a number has fewer digits, they will\nbe prefixed by leading zeroes (or another character, see: ``--index-pad-with``).\nA special value of ``auto`` can be used to automatically pad enough digits so\nthat each filename has the same amount of them used. This is useful for ensuring\nyour files will be sorted correctly even by dumb algorithms. Default:\n``--index-digits=auto``.\n\n--index-pad-with\n~~~~~~~~~~~~~~~~\nWhen using the special ``\\(index)`` reference, this option specifies what\ncharacter will be used for padding. Default: ``--index-pad-with=0``. \n\n--selftest\n~~~~~~~~~~\nRuns internal unit tests of all functionality. Does actual renaming of\na generated set of files in the specified directory. If no directory is passed,\nuses the temporary directory. Each test generates its own set of files.\n\nInstallation\n============\n\nThis script requires Python 2.4+ with the `argparse\n`_ library. It can be used standalone or\ninstalled using ``pip`` or ``easy_install``::\n\n pip install rename\n easy_install rename\n\nDon't have either of these? You can always grab the latest source release from\nthe `PyPI website `_ or better yet\nequip yourself with ``easy_install`` by downloading and running\n`distribute_setup.py `_.\n\nSecurity\n========\n\n1. The script will not let multiple files be renamed to a single name.\n\n2. The script will not let existing files to be overwritten.\n\n3. Both checks above are made for all matches before any renaming is performed.\n\n4. The script correctly preserves extended attributes and ACLs.\n\nOther remarks\n=============\n\n1. Regular expressions supported by the script must conform to the syntax\n handled by Python's `re `_ module.\n\n2. Actual renaming of a single file is done by the `os.rename()\n `_ function from Python's\n standard library. No additional atomicity is ensured, e.g. if a single rename\n fails halfway through, the filesystem is left in a state of partially\n complete renaming.\n\n3. Due to differences in behaviour of different shells, the recommended form of\n execution is to put both arguments in quotation marks.\n\nPossible future enhancements\n============================\n\n1. ``-p`` option to create intermediate directories for the target. One tiny\n problem is maintaining atomicity of the whole transaction.\n\n2. ``-r`` option to make the source match recursive. Tricky to get right\n I guess, e.g. where to rename? Existing directory structure or new one?. Let\n the user decide? What's the default? Etc. etc.\n\n3. Interactive mode. Things to be thought over: should the question appear\n before the transaction begins, before each step, or both? Should that be one\n option?\n\nBFD: BIG FRIENDLY DISCLAIMER\n============================\n\nThis program is free software: you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free Software\nFoundation, version 3 of the License.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\nA PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\n**DON'T PANIC**. This code has been successfully used by its author and\ncontains tests. However, be especially wary under these conditions:\n\n1. Renaming between filesystems.\n\n2. Renaming under non case-preserving filesystems.\n\n3. Renaming within very long paths.\n\n4. Renaming volatile state (e.g. rotating logs).\n\nAnd if you do lose any data, it's your fault. Have a nice day!\n\nAuthors\n=======\n\nScript glued together by `\u0141ukasz Langa `_.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/langacore/rename", "keywords": "", "license": "GPL v3", "maintainer": null, "maintainer_email": null, "name": "rename", "package_url": "https://pypi.org/project/rename/", "platform": "any", "project_url": "https://pypi.org/project/rename/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/langacore/rename" }, "release_url": "https://pypi.org/project/rename/1.2/", "requires_dist": null, "requires_python": null, "summary": "Renames files using regular expressions", "version": "1.2" }, "last_serial": 649223, "releases": { "1.0b1": [ { "comment_text": "", "digests": { "md5": "6cad04de06185ad9f7be4bbd641d4129", "sha256": "516ff4982ed1b3ae63089bc2ca6f34e820ec02d2e09850f9787332224a9c3ba4" }, "downloads": -1, "filename": "rename-1.0b1.tar.gz", "has_sig": false, "md5_digest": "6cad04de06185ad9f7be4bbd641d4129", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3715, "upload_time": "2010-10-19T09:26:14", "url": "https://files.pythonhosted.org/packages/4e/93/bf3d730e92921451c72aae5cf947754fd6d0af0fce502e6e412b21d344ef/rename-1.0b1.tar.gz" } ], "1.0b2": [ { "comment_text": "", "digests": { "md5": "beb3fe73b5d5004fd6de67bbed42e634", "sha256": "59b8dedd280b1e30f23d4eedbefc4c532565b2d3441c1ef7a52c350724eebe1c" }, "downloads": -1, "filename": "rename-1.0b2.tar.gz", "has_sig": false, "md5_digest": "beb3fe73b5d5004fd6de67bbed42e634", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18917, "upload_time": "2010-10-19T12:02:44", "url": "https://files.pythonhosted.org/packages/29/75/ec15fd524df82b3573b332b2769f32f076f1bed3f67b8aff1eb434d5e69e/rename-1.0b2.tar.gz" } ], "1.0c1": [ { "comment_text": "", "digests": { "md5": "f4c03fc9e4d576e4306cec27973fdc55", "sha256": "fff23876cd805d95d71558f285f2d1a892d2ed9ef8589b947e0e03044d798179" }, "downloads": -1, "filename": "rename-1.0c1.tar.gz", "has_sig": false, "md5_digest": "f4c03fc9e4d576e4306cec27973fdc55", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18869, "upload_time": "2011-02-13T03:25:37", "url": "https://files.pythonhosted.org/packages/3e/5b/55b4034a1bbba99a9c848afe61a7260d14565fa304c6f8cd71f6631eb050/rename-1.0c1.tar.gz" } ], "1.0c2": [ { "comment_text": "", "digests": { "md5": "4a7d82149326131c62273f517624fb10", "sha256": "3773e661aad48de8616d9ed3bc6a0a6394d8c572c97a80ad9388af03d9117353" }, "downloads": -1, "filename": "rename-1.0c2.tar.gz", "has_sig": false, "md5_digest": "4a7d82149326131c62273f517624fb10", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18887, "upload_time": "2011-02-13T03:45:05", "url": "https://files.pythonhosted.org/packages/b6/d8/6b232b8722f748cd33ac4d373c487812866dfb8bd5138612fc55887d75bf/rename-1.0c2.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "3ec8b478f5d74a63b980f8ca10d308d9", "sha256": "a17414971ce1ed06ff28a163aa85b55e06469a8860023ae637321b4a3ecc63e2" }, "downloads": -1, "filename": "rename-1.1.tar.gz", "has_sig": false, "md5_digest": "3ec8b478f5d74a63b980f8ca10d308d9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21316, "upload_time": "2011-07-10T15:39:16", "url": "https://files.pythonhosted.org/packages/46/2e/1b1c1714ca2fa1f80e8eb2eba4a7bcb817b9c20b935e751add65f4c1e5b9/rename-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "dc66bbc434c3bea1c37f1652e603ac91", "sha256": "c43255842322ffebde406eff3fca3543f8305025df28ea129898869c49a15fcb" }, "downloads": -1, "filename": "rename-1.2.tar.gz", "has_sig": false, "md5_digest": "dc66bbc434c3bea1c37f1652e603ac91", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22706, "upload_time": "2011-08-26T15:09:31", "url": "https://files.pythonhosted.org/packages/7a/7e/c1d324d3fa3e84c4520da341b60d178c252d0268174eac11383ac9a37f01/rename-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dc66bbc434c3bea1c37f1652e603ac91", "sha256": "c43255842322ffebde406eff3fca3543f8305025df28ea129898869c49a15fcb" }, "downloads": -1, "filename": "rename-1.2.tar.gz", "has_sig": false, "md5_digest": "dc66bbc434c3bea1c37f1652e603ac91", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22706, "upload_time": "2011-08-26T15:09:31", "url": "https://files.pythonhosted.org/packages/7a/7e/c1d324d3fa3e84c4520da341b60d178c252d0268174eac11383ac9a37f01/rename-1.2.tar.gz" } ] }