summaryrefslogtreecommitdiff
path: root/rename.sh
blob: a656d073612905d46c290b74c4651fa7b572c961 (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="citron"
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