rename
Renames one or more files or directories. Windows commands reference
On Windows, Linux
Windows
Renames one or more files or directories. Use wildcard characters (* and ?) to rename multiple files in a single command. NOTE: This command is the same as the ren command.
rename [<drive>:][<path>]<filename1> <filename2>rename *.txt *.docrename img*.jpg pic*.jpgrename ??-*.log ??_*.logrename *.log *.log.bakrename chap10 part10
[<drive>:][<path>]<filename1>Specifies the location and name of the file or set of files you want to rename. Filename1 can include wildcard characters (* and ?).<filename2>Specifies the new name for the file. Use wildcard characters to specify new names for multiple files./?Shows help at the command prompt.img001.jpgpic001.jpgimg_final.jpgpic_final.jpgab-server.logab_server.logdb-audit.logdb_audit.logserver.logserver.log.bakapp.debug.logapp.debug.log.bakSeveral platforms
Rename a file or group of files with a regex. WARNING: This command will overwrite files without prompting unless the -n option is used. Note: This page refers to the Perl version, also known as file-rename.
Replace from with to in the filenames of the specified files
rename 's/from/to/' *.txtIdentifySimulate running the program without doing anything
rename -n 's/from/to/' *.txtIdentifyChange the extension
rename 's/\.old$/\.new/' *.txtIdentifyChange to lowercase (use -f in case-insensitive filesystems)
rename --force 'y/A-Z/a-z/' *.txtIdentifyCapitalize first letter of every word in the name
rename --force 's/\b(\w)/\U$1/g' *.txtIdentifyReplace spaces with underscores
rename 's/\s+/_/g' *.txtIdentifyLinux
rename can refer to multiple commands with the same name.