Skip to main content

Motivation

If you want to rename files in a directory, things get really cumbersome if:

  • the name modifications are not easily automatable (e.g. spelling mistakes)

  • file names contain spaces / special characters (when using a shell)

  • you have to rename a lot of files (when using a GUI)

  • you would need to use temporary files (e.g. mv a tmp ; mv b a ; mv tmp b)

  • etc.

This script launches a used-defined text editor with a temporary file, where every line is a filename in the directory. This enables the user to rename (edit a line) or delete (blank line) entries. After saving and exiting the editor, the script checks the file for consistency, detects rename loops and finally performs the changes.

News

3.1.0

2025-11-28

Require Python 3.9, small test fixes

3.0.0

2021-03-29

Require Python 3.6 (no new features, just usage of “try … from”)

2.1.0

2017-05-01

Support renaming of intermediate dirs in recursive mode, drop --safe mode, small bugfixes

2.0.0

2017-03-22

Bugfixes, Python 3 support, -o and -L option, extensive test suite

1.1

2010-11-21

Bugfixes

1.0

2010-05-06

First working version

Examples

Rename non-hidden files in the current directory:

dir_edit

Rename mp3 files in the music directory using gedit:

dir_edit -e gedit ~/Music ~/Music/*.mp3

Review changes before executing them:

dir_edit -vd -L log.txt
view log.txt
sh -e log.txt

Rename pictures with maximum directory depth 2:

find pics -maxdepth 2 -type f -iregex ".*\.\(jpg\|png\)" > file_list
dir_edit -i file_list

Usage

dir_edit [OPTION]... [DIR] [FILES]...

  DIR        directory to edit (default: current directory)
  FILES      limit to these filenames (default: all non-hidden in directory)

Some options:

  -e CMD, --editor=CMD       use CMD to edit dirfile (default: $EDITOR or vi)
  -d, --dry-run              don't perform any file system modifications
  -v, --verbose              output filesystem modifications to stdout
  -L FILE, --logfile FILE    path to logfile for verbose mode (default: stdout)
  -i FILE, --input FILE      FILE containing paths to be edited

Metadata

Release files for dir-edit 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dir-edit 3.1.0
File Size Uploaded Provenance Actions
dir_edit-3.1.0.tar.gz 20.2 kB Without provenance Details for dir_edit-3.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dir-edit 3.1.0
File Interpreter ABI Platform Actions
dir_edit-3.1.0-py3-none-any.whl Python 3 none any Details for dir_edit-3.1.0-py3-none-any.whl

Total release size: 40.7 kB

Release files / dir_edit-3.1.0.tar.gz

Download URL dir_edit-3.1.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e0efea3d49d731239671f873718b5511f56583ab3d4985cc92999fcf68e29274
BLAKE2b-256 checksum
How to use checksums
6d466f8dbab8d55d24dec65c453a41a646397c84808eadfdaaacdc056690b751
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / dir_edit-3.1.0-py3-none-any.whl

Download URL dir_edit-3.1.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ede11c1d82043dc584c7f93af2eb727414086dab1b75c0ed4437a0b3a9aca97
BLAKE2b-256 checksum
How to use checksums
aa6fb57a67ab9ed2794d3c30df97163e6f555087155b4142f5b964432db26b92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for dir-edit 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page