summaryrefslogtreecommitdiff
path: root/rename.sh
blob: 84906842d01056b9d8d76d51d78b72c3271d21b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

# Define old and new strings
old="yuzu"
new="citron"

# Find and rename directories first
find . -depth -type d -name "*${old}*" | while read -r dir; do
    newdir=$(echo "$dir" | sed "s/${old}/${new}/g")
    mv "$dir" "$newdir"
done

# Find and rename files
find . -depth -type f -name "*${old}*" | while read -r file; do
    newfile=$(echo "$file" | sed "s/${old}/${new}/g")
    mv "$file" "$newfile"
done