rename txt files bash
🧩 Syntax:
To rename all
.txtfiles in the current working directory (CWD) to.mdusing Bash, you can use therenamecommand or aforloop. Here's how you can do it:Using the
renamecommand:rename 's/\.txt$/.md/' *.txtThis command uses regular expressions to match the
.txtextension at the end of the file names and replaces it with.md.Using a
forloop:for file in *.txt; do mv -- "$file" "${file%.txt}.md" doneThis loop iterates over all
.txtfiles in the current directory, and for each file, it uses themvcommand to rename it by removing the.txtextension and appending.mdinstead.Both methods achieve the same result of renaming all
.txtfiles in the CWD to.md. Choose the one that suits your preference or the tools available in your system.