Skip to content

File and Directory Renaming

In addition to replacing text within files, Renamify can rename files and directories that match your pattern.

Any file whose name contains your search pattern will be renamed:

  • getUserName.jsfetchUserProfile.js
  • get_user_name.pyfetch_user_profile.py
  • GetUserName.tsxFetchUserProfile.tsx

Directory names are also transformed:

  • user-name/user-profile/
  • getUserName/fetchUserProfile/

Renamify renames in dependency order:

  1. Files first
  2. Then directories, deepest first This prevents conflicts and ensures all operations succeed.

NEW: Renamify can now rename the project root directory itself when the directory name matches your pattern.

  • Default behavior: Root directory renaming is disabled for safety
  • Enable with --rename-root: Explicitly allow root directory renaming
  • Manual confirmation: Always requires interactive confirmation
  • Next steps snippet: Provides instructions for rebuilding/reloading after root rename
Terminal window
# This will offer to rename the project directory itself
cd /path/to/renamify-project
renamify rename renamify renamed_renaming_tool --rename-root

Renamify will show a “Next Steps” snippet like:

Next Steps:
1. cd ../renamed-renaming-tool-project
2. cargo build --release # if Rust project
3. Update any IDE project settings
  • Always commit changes before root directory rename
  • Update build scripts, IDE settings, and documentation paths
  • Consider impact on CI/CD pipelines that reference the directory name
Terminal window
renamify rename old_name new_name --no-rename-files
Terminal window
renamify rename old_name new_name --no-rename-dirs
Terminal window
renamify rename old_name new_name --no-rename-root
Terminal window
renamify rename getUserName fetchUserProfile

Might show:

Files to rename: 3
┌─────────────────────────────────────┬─────────────────────────────────────┐
│ Current Path │ New Path │
├─────────────────────────────────────┼─────────────────────────────────────┤
│ src/getUserName.js │ src/fetchUserProfile.js │
│ components/GetUserName.tsx │ components/FetchUserProfile.tsx │
│ tests/get_user_name.test.py │ tests/fetch_user_profile.test.py │
└─────────────────────────────────────┴─────────────────────────────────────┘
Terminal window
renamify rename myproject awesome_project --rename-root

This could rename:

  • The root directory: myproject/awesome_project/
  • Files: myproject.config.jsawesome_project.config.js
  • Directories: src/myproject/src/awesome_project/
  • Content references within files

Renamify detects several types of renaming conflicts:

When multiple files would be renamed to the same destination:

❌ Error: Multiple files would be renamed to 'utils.js':
- old_utils.js
- oldUtils.js

On macOS and Windows (case-insensitive filesystems):

⚠️ Warning: Renaming 'OldName.js' to 'oldName.js' requires special handling

Renamify uses two-step renames for case-only changes:

  1. OldName.jstemp_12345.js
  2. temp_12345.jsoldName.js

Prevents creating files with Windows reserved names:

❌ Error: Cannot create file 'CON.js' (Windows reserved name)
  • Handles case-sensitive and case-insensitive filesystems
  • Supports long file paths
  • Preserves file permissions
  • Handles path length limitations (260 chars)
  • Prevents reserved filenames (CON, PRN, AUX, etc.)
  • Supports both forward and backward slashes
  • Symlink files can be renamed if their names match
  • Symlink targets are never modified
  • By default, symlinks are not followed during traversal