Skip to main content

Posts

Showing posts from October, 2025

Linux Bash rename multiple files

Bash script/command below shows how to rename multiple files. If the filename shows some pattern, then it will be easier to rename.  Example filename: file_text_a.txt file_text_b.txt file_text_c.txt file_text_etc... ... .txt Script/command below, shows some magic to rename files all at once. The command below can be integrated to a script or simply run the command on the terminal. Create some dummy files for testing before running on actual files to be renamed or in production. find . -name "*.txt" -exec sh -c '   for file; do       newf=$(echo "$file" | sed "s/text/tested/" )  &&   mv "$file" "$newf"   done ' sh {} + Output is: file_tested_a.txt file_tested_b.txt Since the command uses sed, replace 'text' with any string to be searches and replace 'tested' also with any new string for the filename. Till next time.. Enjoy Linux and scripting... Put your trust in God and have Faith. Exodus 14:14, "The...