CmdID

CmdID / Commands

rename

Renames one or more files or directories. Windows commands reference

On Windows, Linux

Opens CmdID with your command. It is read in your browser and sent nowhere.

Windows

from the Windows commands reference, CC BY 4.0

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 *.doc
rename img*.jpg pic*.jpg
rename ??-*.log ??_*.log
rename *.log *.log.bak
rename 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.jpg
img_final.jpgpic_final.jpg
ab-server.logab_server.log
db-audit.logdb_audit.log
server.logserver.log.bak
app.debug.logapp.debug.log.bak

Several platforms

from tldr-pages, CC BY 4.0

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/' *.txtIdentify

Simulate running the program without doing anything

rename -n 's/from/to/' *.txtIdentify

Change the extension

rename 's/\.old$/\.new/' *.txtIdentify

Change to lowercase (use -f in case-insensitive filesystems)

rename --force 'y/A-Z/a-z/' *.txtIdentify

Capitalize first letter of every word in the name

rename --force 's/\b(\w)/\U$1/g' *.txtIdentify

Replace spaces with underscores

rename 's/\s+/_/g' *.txtIdentify

rename can refer to multiple commands with the same name.