🖥️rename
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the rename command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ███████╗███╗ ██╗ █████╗ ███╗ ███╗███████╗
# ██╔══██╗██╔════╝████╗ ██║██╔══██╗████╗ ████║██╔════╝
# ██████╔╝█████╗ ██╔██╗ ██║███████║██╔████╔██║█████╗
# ██╔══██╗██╔══╝ ██║╚██╗██║██╔══██║██║╚██╔╝██║██╔══╝
# ██║ ██║███████╗██║ ╚████║██║ ██║██║ ╚═╝ ██║███████╗
# ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝
# Lowercase all files and folders in current directory
rename 'y/A-Z/a-z/' *
rename 's/.html$/.php/' *.html
# Rename replaces string X in a set of file names with string Y. -> This will change the extension of every .html file in your CWD to .php.
rename 's/^unwanted//' *.jpg
# Remove the prefix 'unwanted' from the beginning of each filename with .jpg suffix in CWD.
rename -v 's/^([0-9])_/0\1_/' *.flac
# Rename all single leading digit flac files so that they have a padding 0 for easier sorting.
exiv2 -k -F rename *.jpg
# Use the exiv2 EXIF program to rename your jpg files according to their exif date/time data.
rename 's/^hospital\.php\?loc=(\d{4})$/hospital_$1/' hospital.php*
# Rename files in batch
# Rename all non-hidden files under current directory by replacing spaces with underscores. Uses Larry Wall's 'rename'
rename 's/ /_/g' *
rename 's/_(\d{4})(\d{2})(\d{2}).txt/_$1-$2-$3.txt/' *_????????.txt
# Rename set of files with non-hyphened date at the end to have hyphens.
rename 's/ /_/g' *
# rename all non-hidden files under current directory by replacing spaces with underscores.
rename 's/^unwanted//' *.jpg
# Remove the prefix 'unwanted' from the beginning of each filename with .jpg suffix in CWD.
# Rename all files in lower case - rename is a really powerfull to, as its name suggests, rename files
rename 'y/A-Z/a-z/' *
# Sample outpt:
# aETEBezhrhe.txt REHTY.txt rthureioght.txt
# becomes :
# aetebezhrhe.txt rehty.txt rthureioght.txt
# If your system has the rename command (Linux), then a shortcut to do the exact same thing is with:
rename 's/\d+/sprintf("%04d", $&)/e' *.jpg
# It handles special characters better too.
# Remove new lines from files and folders
rename 's/[\r\n]//g' *
# Explanation: This will search all files and folders in the current directory for any with a new line character in them and remove the new line out of the file/folder.
#==============================##==============================#
# CMD RENAME #
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command rename in a clear format. This allows users to quickly access the needed information for rename without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for rename are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.