-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcoppy_configs.sh
executable file
·43 lines (34 loc) · 1.17 KB
/
coppy_configs.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# Set the source and destination directories
src_dir="~/Documents/bspwm_dotfiles/.config"
dst_dir="~/.config"
# Loop through all the directories in the source directory
for dir in "$src_dir"/*/
do
# Get the name of the directory
dir_name=$(basename "$dir")
# Check if the directory already exists in the destination directory
if [ -d "$dst_dir/$dir_name" ]
then
# If it does, append a timestamp to the directory name
timestamp=$(date +%Y%m%d%H%M%S)
dir_name="$dir_name-$timestamp"
fi
# Copy the directory from the source to the destination directory
cp -r "$dir" "$dst_dir/$dir_name"
done
# Loop through all the files in the source directory
for file in "$src_dir"/*
do
# Get the name of the file
file_name=$(basename "$file")
# Check if the file already exists in the destination directory
if [ -f "$dst_dir/$file_name" ]
then
# If it does, append a timestamp to the file name
timestamp=$(date +%Y%m%d%H%M%S)
file_name="$file_name-$timestamp"
fi
# Copy the file from the source to the destination directory
cp -r "$file" "$dst_dir/$file_name"
done