{"id":16389687,"url":"https://github.com/igaray/name_pryer","last_synced_at":"2025-07-11T14:09:36.724Z","repository":{"id":149118550,"uuid":"13607780","full_name":"igaray/name_pryer","owner":"igaray","description":"A file name manipulation tool.","archived":false,"fork":false,"pushed_at":"2018-06-14T16:59:05.000Z","size":56,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T23:27:47.818Z","etag":null,"topics":["file-handling","tool"],"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-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igaray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING.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-10-16T02:32:36.000Z","updated_at":"2018-06-14T16:59:07.000Z","dependencies_parsed_at":"2023-05-05T02:31:08.246Z","dependency_job_id":null,"html_url":"https://github.com/igaray/name_pryer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igaray%2Fname_pryer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igaray%2Fname_pryer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igaray%2Fname_pryer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igaray%2Fname_pryer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igaray","download_url":"https://codeload.github.com/igaray/name_pryer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247189063,"owners_count":20898620,"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":["file-handling","tool"],"created_at":"2024-10-11T04:33:59.955Z","updated_at":"2025-04-04T13:42:57.439Z","avatar_url":"https://github.com/igaray.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Name Pryer\n\n**pry** *transitive verb*\n\n1. to raise, move, or pull apart with a lever: prize\n2. to extract, detach, or open with difficulty \u003cpried the secret out of my sister\u003e\n\n**pry** *noun*\n\n1. a tool for prying\n2. leverage\n\n### Overview\n\n**name-pryer** is a simple command-line script for manipulating file names, a file name swiss army knife. It operates on single files or groups of files by populating a buffer with a listing of files, parsing the arguments to generate a sequence of actions, processing the actions in order and applying their effects to the contents of the file name buffer. The final state for each file name is shown and confirmation is requested before renaming the files.\n\n**Feature Overview**:\n* `-h` will emit a helpful text with available flags\n* `-v` allows setting the verbosity level\n* `-y` yes mode will skip confirmation\n* `-u` will create an undo script\n* `-F FILENAME` will operate on a single file\n* `-D DIR` will set the working directory\n* `-R` will recurse directories\n* `-M [f | d | b]` allows operating only on files, directories or both\n* `-g GLOB` allows specifying a glob pattern to match files\n* `-p` allows specifying a pattern with fields, extracting those fields into the new filename, and generating values such as counters, random numbers, and dates\n* `-c [lc | uc | tc | sc]` allows changing to upper, lower, sentence or title case\n* `-C` allows splitting words in camel case\n* `+C` allows joining words separated by underscores into camel case\n* `-d X (Y | end)` allows deleting a region\n* `-i X (Y | end)` allows inserting\n* `-n` will sanitize the filename, removing all non-alphanumeric characters\n* `+e EXT` allows adding an extension\n* `-e [EXT]` allows modifying the extension or removing it if not specified\n* `-r X Y` allows replacing characters\n* `-s` is a shortform for substituting spaces, periods, dashes and underscores\n* `-t` will tokenize the filename and allow selecting which tokens remaing and in which order\n* `--git` will rename the files by calling `git mv`\n\n### License and Credits\n\n**name-pryer** is an anagram of [pyRenamer](https://github.com/SteveRyherd/pyRenamer) by Adolfo González Blázquez, from which it inherits much.\nOther work similar to this:\n* [kevbradwick/pyrenamer](https://github.com/kevbradwick/pyrenamer)\n* [italomaia/renamer](https://github.com/italomaia/renamer)\n* [Donearm/Renamer](https://github.com/Donearm/Renamer)\n\nThe original **pyRenamer** has a GPL 2 license, and since I used its code for the pattern match operator, this is what **name-pryer** has.\n\n### Requirements\n\n**name-pryer** requires Python 3 and has no other dependencies. It has been tested only on Linux.\n\n### Installation\n\n**name-pryer** is a stand-alone script. Just download the ``name-pryer.py`` file, set it as executable, put it in your ``$PATH`` and alias to your finger's content.\n\n### Flags without effects on file names\n\n``-h``\n\nHelp. Print a message with a summary of the options.\n\n---\n``-v 0 -v 1 -v 2 -v 3``\n\nVerbosity level.\n\n* Level 0 is silent running and will produce no output.\n* Level 1 will show the final state of the file name buffer and is the default.\n* Level 2 will in addition list the actions to be applied.\n* Level 3 will in addition show the state of the file name buffer at each step.\n\nThe ``-v X`` flags count as actions, but do not affect the file name buffer. They can be listed several times with different levels, interspersed among the other actions to raise or lower the verbosity during operation.\n\nIf the ``-v 2`` or ``-v 3`` parameter is present, regardless of position, a list of actions will be output at the beginning.\n\n---\n``-y``\n\nYes mode. Do not ask for confirmation. Useful for non-interactive batch scripts.\n\n* Example:\n\n```bash\n$ np -v 0 -y -s us\n```\n\n---\n``-u``\n\nCreates a script `undo.sh` which may be run to undo the last renaming operations.\n\n### Filters\n\nFilters will specify which files remain in the buffer in addition to applying transformations on the file names therein. They affect how the file name buffer is populated, before any actions are applied.\n\n---\n``-F FILE``\n\nOperate on a single file instead of all files in the current directory. Essentially drops all file names from the buffer that do not match its value exactly.\n\n* Example\n\n```bash\n$ ls\nfolder  eighth_ninth_tenth.txt  fifth_sixth_seventh.txt  first_second_third_fourth.txt\n\n$ np -F eighth_ninth_tenth.txt -s us\neighth_ninth_tenth.txt =\u003e eighth ninth tenth.txt\n\ny/n?\n```\n\n---\n``-M [f | d | b]``\n\nOperation mode.\n\n* Options:\n  * **f**: Operate only on files (default).\n  * **d**: Operate only on directories.\n  * **b**: Operate both on directories and files.\n\n* Example\n\n```bash\n$ ls -l\ntotal 4\ndrwxr-xr-x 3 igaray igaray 4096 Dec 28 05:26 folder\n-rw-r--r-- 1 igaray igaray    0 Dec 28 04:22 eighth_ninth_tenth\n-rw-r--r-- 1 igaray igaray    0 Dec 28 04:21 fifth_sixth_seventh\n-rw-r--r-- 1 igaray igaray    0 Dec 27 21:04 first_second_third_fourth\n\n$ np -M f +e txt\neighth_ninth_tenth        =\u003e eighth_ninth_tenth.txt\nfifth_sixth_seventh       =\u003e fifth_sixth_seventh.txt\nfirst_second_third_fourth =\u003e first_second_third_fourth.txt\n\n$ np -M d +e txt\nfolder =\u003e folder.txt\n\n$ np -M b +e txt\neighth_ninth_tenth        =\u003e eighth_ninth_tenth.txt\nfifth_sixth_seventh       =\u003e fifth_sixth_seventh.txt\nfirst_second_third_fourth =\u003e first_second_third_fourth.txt\nfolder                    =\u003e folder.txt\n```\n\n---\n``-D DIR``\n\nSet working directory. Default is current directory.\n\n---\n``-R``\n\nRecurse directories, may be used in combination with `-m` and `-D` and `-g`.\n\n---\n``-g GLOB``\n\nOperate only on files matching the glob pattern, e.g. `-g \"*.mp3\"`.\n\n* Examples\n\n```bash\n$ tree\n.\n├── eighth_ninth_tenth.txt\n├── fifth_sixth_seventh.txt\n├── first_second_third_fourth.txt\n└── folder\n    ├── eighth_ninth_tenth.txt\n    └── folder2\n        └── fifth_sixth_seventh2.txt\n\n2 directories, 5 files\n\n# Add extension 666, only to files in the current directory.\n$ np +e 666\neighth_ninth_tenth.txt        =\u003e eighth_ninth_tenth.666\nfifth_sixth_seventh.txt       =\u003e fifth_sixth_seventh.666\nfirst_second_third_fourth.txt =\u003e first_second_third_fourth.666\n\n# Add extension 666, only to files in the current directory starting with f.\n$ np -g \"f*\" +e 666\nfifth_sixth_seventh.txt       =\u003e fifth_sixth_seventh.666\nfirst_second_third_fourth.txt =\u003e first_second_third_fourth.666\n\n# Add extension 666 recursively, defaults to only files.\n$ np -R +e 666\n/home/igaray/tmp/test/eighth_ninth_tenth.txt\n    =\u003e /home/igaray/tmp/test/eighth_ninth_tenth.666\n/home/igaray/tmp/test/fifth_sixth_seventh.txt\n    =\u003e /home/igaray/tmp/test/fifth_sixth_seventh.666\n/home/igaray/tmp/test/first_second_third_fourth.txt\n    =\u003e /home/igaray/tmp/test/first_second_third_fourth.666\n/home/igaray/tmp/test/folder/eighth_ninth_tenth.txt\n    =\u003e /home/igaray/tmp/test/folder/eighth_ninth_tenth.666\n/home/igaray/tmp/test/folder/folder2/fifth_sixth_seventh2.txt\n    =\u003e /home/igaray/tmp/test/folder/folder2/fifth_sixth_seventh2.666\n\n# Add extension 666 recursively, only to files starting with the letter f.\n$ np -R -g \"f*\" +e 666\n/home/igaray/tmp/test/fifth_sixth_seventh.txt\n    =\u003e /home/igaray/tmp/test/fifth_sixth_seventh.666\n/home/igaray/tmp/test/first_second_third_fourth.txt\n    =\u003e /home/igaray/tmp/test/first_second_third_fourth.666\n/home/igaray/tmp/test/folder/folder2/fifth_sixth_seventh2.txt\n    =\u003e /home/igaray/tmp/test/folder/folder2/fifth_sixth_seventh2.666\n\n# Add extension 666 recursively, only to directories starting with f.\n$ np -M d -R -g \"f*\" +e 666\n/home/igaray/tmp/test/folder         =\u003e /home/igaray/tmp/test/folder.666\n/home/igaray/tmp/test/folder/folder2 =\u003e /home/igaray/tmp/test/folder/folder2.666\n\n# Add extension 666 recursively, to both files and directories starting with f.\n$ np -M b -R -g \"f*\" +e 666\n/home/igaray/tmp/test/fifth_sixth_seventh.txt\n    =\u003e /home/igaray/tmp/test/fifth_sixth_seventh.666\n/home/igaray/tmp/test/first_second_third_fourth.txt\n    =\u003e /home/igaray/tmp/test/first_second_third_fourth.666\n/home/igaray/tmp/test/folder\n    =\u003e /home/igaray/tmp/test/folder.666\n/home/igaray/tmp/test/folder/folder2\n    =\u003e /home/igaray/tmp/test/folder/folder2.666\n/home/igaray/tmp/test/folder/folder2/fifth_sixth_seventh2.txt\n    =\u003e /home/igaray/tmp/test/folder/folder2/fifth_sixth_seventh2.666\n```\n\n---\n``-p SOURCE_PATTERN DESTINATION_PATTERN``\n\nThe pattern matching filter makes regular expressions usable.\nThis is the most useful operator and is taken directly from **pyRenamer**'s code.\n\n**Pattern**     | **Description**\n----------------|----------------\n``{#}``         | Numbers\n``{L}``         | Letters\n``{C}``         | Characters (Numbers \u0026 letters, not spaces)\n``{X}``         | Numbers, letters, and spaces\n``{@}``         | Trash\n``{numX+Y}``    | Generates a number, padded to **X** characters with leading 0s, stepping by **Y**. **X** may be absent. **Y** may be absent and defaults to 1.\n``{rand}``      | Generates a random number from 0 to 100.\n``{randX}``     | Generates a random number from 0 to **X**.\n``{randX-Y}``   | Generates a random number from **X** to **Y**.\n``{randX-Y,Z}`` | Generates a random number from **X** to **Y**, padded to **Z**. characters.\n``{date}``      | Generates the date (e.g. 2014-12-31)\n``{year}``      | Generates the year (e.g. 2014)\n``{month}``     | Generates the month number (e.g. 12)\n``{monthname}`` | Generates the month’s name (December)\n``{monthsimp}`` | Generates the months abbreviated name (e.g. Dec)\n``{day}``       | Generates the day’s number (31)\n``{dayname}``   | Generates the day’s name (e.g. Wednesday)\n``{daysimp}``   | Generates the day’s abbreviated name (e.g. Wed)\n\n* Examples\n\nTODO\n\n---\n```bash\n% pwd\n/Users/inaki/Music/Thriftworks - Deviation (2013)/Thriftworks - Deviation (2013)\n\n% ls -1\n01 - Untrue.mp3\n02 - Fits the Bill.mp3\n03 - Feeding Time.mp3\n04 - Someone (feat. Oriel Poole).mp3\n05 - The Touch.mp3\n06 - Metal Tho.mp3\n07 - Terminally Chill.mp3\n08 - Nanometer.mp3\n\n% name-pryer.py -v 3 -p \"{#} - {X}\" \"{1} {2}\"\nactions:\nverbosity 3\npattern   {#} - {X} {1} {2}\n\nsetting verbosity level to 3\n----------------------------------------------------------------------\npattern {#} - {X} {1} {2}\n01 - Untrue.mp3                      =\u003e 01 Untrue.mp3\n02 - Fits the Bill.mp3               =\u003e 02 Fits the Bill.mp3\n03 - Feeding Time.mp3                =\u003e 03 Feeding Time.mp3\n04 - Someone (feat. Oriel Poole).mp3 =\u003e 04 Someone (feat. Oriel Poole).mp3\n05 - The Touch.mp3                   =\u003e 05 The Touch.mp3\n06 - Metal Tho.mp3                   =\u003e 06 Metal Tho.mp3\n07 - Terminally Chill.mp3            =\u003e 07 Terminally Chill.mp3\n08 - Nanometer.mp3                   =\u003e 08 Nanometer.mp3\n\ny/n?\ny\n\n% ls -1\n01 Untrue.mp3\n02 Fits the Bill.mp3\n03 Feeding Time.mp3\n04 Someone (feat. Oriel Poole).mp3\n05 The Touch.mp3\n06 Metal Tho.mp3\n07 Terminally Chill.mp3\n08 Nanometer.mp3\n```\n\n### Transformations\n\nTransformations visit every file name in the buffer and transform them in some way. None of the transformations will affect the extension or the period just before the extension.\n\n---\n``-C``\n\nSplit words in camelCase.\n\n* Example\n\n```bash\n% ls -1\nfolder\nEighthNinthTenth.txt\nFifthSixthSeventh.txt\nFirstSecondThirdFourth.txt\n\n$ np -C\nEighthNinthTenth.txt       =\u003e Eighth Ninth Tenth.txt\nFifthSixthSeventh.txt      =\u003e Fifth Sixth Seventh.txt\nFirstSecondThirdFourth.txt =\u003e First Second Third Fourth.txt\n\ny/n?\n\n% ls -1\nfolder\nEighth Ninth Tenth.txt\nFifth Sixth Seventh.txt\nFirst Second Third Fourth.txt\n```\n\n---\n``+C``\n\nJoin words separated by underscores into camelCase.\n\n* Example\n\n```bash\n% ls -1\nfolder\neighth_ninth_tenth.txt\nfifth_sixth_seventh.txt\nfirst_second_third_fourth.txt\n\n$ np +C\neighth_ninth_tenth.txt        =\u003e EighthNinthTenth.txt\nfifth_sixth_seventh.txt       =\u003e FifthSixthSeventh.txt\nfirst_second_third_fourth.txt =\u003e FirstSecondThirdFourth.txt\n\ny/n?\n\n% ls -1\nfolder\nEighthNinthTenth.txt\nFifthSixthSeventh.txt\nFirstSecondThirdFourth.txt\n```\n\n---\n``-c [lc | uc | tc | sc]``\n\nChange case.\nIf you wish to capitalize the extension, use the ``-e`` flag.\n\n* Options\n  * **lc**: lowercase\n  * **uc**: uppercase\n  * **tc**: title case\n  * **sc**: sentence case\n\n* Examples\n\n```bash\n$ ls\nfolder  eighth_ninth_tenth  fifth_sixth_seventh  first_second_third_fourth\n\n$ np -c uc\neighth_ninth_tenth        =\u003e EIGHTH_NINTH_TENTH\nfifth_sixth_seventh       =\u003e FIFTH_SIXTH_SEVENTH\nfirst_second_third_fourth =\u003e FIRST_SECOND_THIRD_FOURTH\n\n$ np -c tc\neighth_ninth_tenth        =\u003e Eighth_Ninth_Tenth\nfifth_sixth_seventh       =\u003e Fifth_Sixth_Seventh\nfirst_second_third_fourth =\u003e First_Second_Third_Fourth\n\n$ np -c sc\neighth_ninth_tenth        =\u003e Eighth_ninth_tenth\nfifth_sixth_seventh       =\u003e Fifth_sixth_seventh\nfirst_second_third_fourth =\u003e First_second_third_fourth\n```\n\n---\n``-d X [Y | end]``\n\nDelete from position X to Y [or end].\nThe end is just before the last period.\n\n* X must be a non-negative integer.\n* Y must be a either the string 'end' or a non-negative integer.\n\n* Examples\n\n```bash\n$ ls\nfolder  eighth_ninth_tenth  fifth_sixth_seventh  first_second_third_fourth\n\n$ np -d 0 4\neighth_ninth_tenth        =\u003e h_ninth_tenth\nfifth_sixth_seventh       =\u003e _sixth_seventh\nfirst_second_third_fourth =\u003e _second_third_fourth\n\n$ np -d 4 end\neighth_ninth_tenth        =\u003e eigh\nfifth_sixth_seventh       =\u003e fift\nfirst_second_third_fourth =\u003e firs\n```\n\n---\n``-i X [Y | end]``\n\nInsert X at position Y [or end].\nThe end is just before the last period.\n\n* X must be a string\n* Y must be either the string 'end' or a non-negative integer\n\n* Examples\n\n```bash\n$ ls\nfolder  eighth_ninth_tenth  fifth_sixth_seventh  first_second_third_fourth\n\n$ np -i xxx_ 0\neighth_ninth_tenth        =\u003e xxx_eighth_ninth_tenth\nfifth_sixth_seventh       =\u003e xxx_fifth_sixth_seventh\nfirst_second_third_fourth =\u003e xxx_first_second_third_fourth\n\n$ np -i xxx_ 6\neighth_ninth_tenth        =\u003e eighthxxx__ninth_tenth\nfifth_sixth_seventh       =\u003e fifth_xxx_sixth_seventh\nfirst_second_third_fourth =\u003e first_xxx_second_third_fourth\n\n$ np -i _xxx end\neighth_ninth_tenth        =\u003e eighth_ninth_tenth_xxx\nfifth_sixth_seventh       =\u003e fifth_sixth_seventh_xxx\nfirst_second_third_fourth =\u003e first_second_third_fourth_xxx\n```\n\n---\n``[+|-]e [EXT]``\n\nModifies the extension.\n* ``+e EXT`` adds the extension to the file name.\n* ``-e`` removes the existing extension from the file name.\n* ``-e EXT`` changes the existing extension to ``EXT``.\n\n* Examples\n\nTODO\n\n---\n``-r X Y``\n\nReplace X with Y.\n\n---\n``-s [sd | sp | su | ud | up | us | pd | ps | pu | dp | ds | du ]``\n\nConvert one character to another.\n\n* Options:\n  * **sd**: spaces to dashes\n  * **sp**: spaces to periods\n  * **su**: spaces to underscores\n  * **ud**: underscores to dashes\n  * **up**: underscores to periods\n  * **us**: underscores to spaces\n  * **pd**: periods to dashes\n  * **ps**: periods to space\n  * **pu**: periods to underscores\n  * **dp**: dashes to periods\n  * **ds**: dashes to spaces\n  * **du**: dashes to underscores\n\n* Examples\n\nTODO\n\n---\n``-n``\n\nSanitizes filenames by removing anything that is not an alphanumeric field.\n\n* Examples\n\nTODO\n\n---\n``-t [1 | 2 | 3]``\n\nInteractive tokenization mode. Tokenizes the file name and prints out each token with a reference character underneath it. It then waits for the user to input a pattern indicating how the tokens should be rearranged.\n\nIf mode is 1, then the input pattern is expected to be simple a space-separated list of token indicators.\n\nIf mode is 2, then the input pattern is expected to be a match expression similar to the ones used with the ``-p`` flag. The input string will be the new filename, after having all occurrences of ``{X}`` patterns replaced, where ``X`` is a token reference.\n\nIf mode is 3, it behaves exactly the same as mode 2 except that the token references do not need to be surrounded by braces, but anything matching a token reference will be replaced by the referenced token.\n\n* Examples\n\nTODO\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figaray%2Fname_pryer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figaray%2Fname_pryer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figaray%2Fname_pryer/lists"}