-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcopy
executable file
·28 lines (24 loc) · 864 Bytes
/
copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
read -p "Enter the filename to be copied (with extension): " old_name
read -p "Enter the new filename (with extension): " new_name
# Function to copy files
copy_files() {
local dir=$1
for filepath in "$dir"/*; do
if [ -d "$filepath" ]; then
# If it's a directory, call the function recursively
copy_files "$filepath"
elif [ -f "$filepath" ] && [[ "$filepath" == *.svg ]]; then
# If it's a file and ends with .svg
filename=$(basename -- "$filepath")
if [[ "$filename" == "$old_name" ]]; then
new_filepath="${dir}/${new_name}"
cp "$filepath" "$new_filepath"
echo "Copied: $filepath to $new_filepath"
fi
fi
done
}
# Start copying from the svg directory
copy_files "svg"
echo "Copying complete."