Remove dots in filename
I wrote a Bash Script to remove excess periods in a filename. For example, if you had a file named “some.words.in.your.filename.txt”, this script will assist in renaming it to “some words in your filename.txt”. Of course, this only works in Linux. You need to save the file below as a .sh and make it executable via the chmod command. Click “Read More” to see the code.
Read more: Remove dots in filename#!/bin/bash
# Get the filename argument
filename="$1"
# Get the extension of the filename
extension="${filename##*.}"
# Remove the extension from the filename
filename="${filename%.*}"
# Replace all dots in the filename with spaces
new_filename="${filename//./ }.$extension"
# Print the suggested new filename
echo "Suggested new filename: $new_filename"
# Prompt the user for confirmation
read -p "Do you want to rename the file? (y/n) " choice
if [[ $choice == "y" || $choice == "Y" ]]; then
# Rename the file
mv "$1" "$new_filename"
echo "File renamed to $new_filename"
else
echo "File not renamed"
fi