{
    "mode": "perldoc",
    "parameter": "rename",
    "section": "-f",
    "url": "https://www.chedong.com/phpMan.php/perldoc/rename/json",
    "generated": "2026-06-03T04:26:15Z",
    "sections": [],
    "flags": [],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Rename a file or group of files with a `regex`.",
        "examples": [
            {
                "description": "Replace `from` with `to` in the filenames of the specified files",
                "command": "rename 's/{{from}}/{{to}}/' {{*.txt}}"
            },
            {
                "description": "Dry-run - display which changes would occur without performing them",
                "command": "rename -n 's/{{from}}/{{to}}/' {{*.txt}}"
            },
            {
                "description": "Change the extension",
                "command": "rename 's/\\.{{old}}$/\\.{{new}}/' {{*.txt}}"
            },
            {
                "description": "Change to lowercase (use `-f` in case-insensitive filesystems)",
                "command": "rename {{-f|--force}} 'y/A-Z/a-z/' {{*.txt}}"
            },
            {
                "description": "Capitalize first letter of every word in the name",
                "command": "rename {{-f|--force}} 's/\\b(\\w)/\\U$1/g' {{*.txt}}"
            },
            {
                "description": "Replace spaces with underscores",
                "command": "rename 's/\\s+/_/g' {{*.txt}}"
            }
        ]
    }
}