Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/potocpav/batch-rename
Rename or move files using Python regular expressions.
https://github.com/potocpav/batch-rename
Last synced: about 2 months ago
JSON representation
Rename or move files using Python regular expressions.
- Host: GitHub
- URL: https://github.com/potocpav/batch-rename
- Owner: potocpav
- Created: 2015-02-26T15:47:37.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-23T21:00:28.000Z (about 7 years ago)
- Last Synced: 2023-08-27T08:59:40.103Z (over 1 year ago)
- Language: Python
- Size: 3.91 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# batch-rename
A script to **batch rename/move** files using **regular expressions**
with **sensible defaults** and **nice output**.
Very similar to perl-rename, but uses Python regular expressions and
interactively asks before a rename.
Tested on GNU/Linux, unlikely to work on other platforms.# Invocation
This is the output of the ```rn --help``` command.
```
usage: rn [-h] [-v] [-q] [-p] [-b] [-c] match replace [file [file ...]]Batch rename files.
positional arguments:
match regexp match
replace regexp replace
file list of files to renameoptional arguments:
-h, --help show this help message and exit
-v, --verbose write information about every moved file
-q, --quiet do not output anything
-p, --pretend just list the mv commands, do not write anything
-b, --batch do not ask before renaming
-c, --copy copy the files instead of just moving
```## Usage
**TL;DR:** Python regexp replace is used
([```re.sub```](https://docs.python.org/2/library/re.html#re.sub)).
Single quote everything.The program asks you before doing anything by default, so feel free to experiment.
### Examples
- Replace underscores with spaces (in all mp3 files):
```bash
rn _ ' ' *.mp3
```- Drop stuff in brackets (in all files in the current directory):
```bash
rn ' \(.*\)' ''
```- Print every letter twice (in all files in the current directory):
```bash
rn '(.)' '\1\1'
```