Bash code snippets
On This Page
Rename all files by pattern in current directory
files=(*)
# Loop through all files
for file in "${files[@]}"
do
# Check if the file name contains the "№" symbol
if [[ $file == *"№"* ]]; then
# Remove everything before and including the "№" symbol
new_file=${file##*"№"}
mv "$file" "$new_file"
echo "Renamed $file to $new_file"
fi
done