-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy
64 lines (54 loc) · 2.28 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Define the home directory and temporary directory
HOME_DIR="/data/data/com.termux/files/home"
TEMP_DIR="/data/data/com.termux/files/tmp"
# Create the temporary directory if it doesn't exist
mkdir -p "$TEMP_DIR"
# Function to check for 'sessions' folder
check_sessions_folder() {
if [ -d "sessions" ]; then
echo -e "\nSuccess: The 'sessions' folder exist."
# Copy the 'sessions' folder to the temporary directory
cp -r "sessions" "$TEMP_DIR"
return 0
else
echo -e "\nError: The 'sessions' folder was not found in $1."
return 1
fi
}
# List directories in the home directory
echo "Select a name of script for sessions to copy:"
cd "$HOME_DIR" || exit 1 # Change to the home directory
# Use select to list directories without full path and without trailing slash
select dir in *; do
# Check if a valid selection was made and if it's a directory
if [ -n "$dir" ] && [ -d "$dir" ]; then
echo -e "\nYou selected: $dir"
# Change to the selected directory
cd "$dir" || exit 1
# Check for the 'sessions' folder
if check_sessions_folder "$dir"; then
# List directories again for pasting the copied folder
echo -e "\nSelect a name of Script to paste the 'sessions' folder:"
cd "$HOME_DIR" || exit 1 # Change back to the home directory
select target_dir in *; do
# Check if a valid selection was made and if it's a directory
if [ -n "$target_dir" ] && [ -d "$target_dir" ]; then
echo -e "\nYou selected: $target_dir"
# Copy the 'sessions' folder from the temporary directory to the selected directory
if cp -r "$TEMP_DIR/sessions" "$HOME_DIR/$target_dir/"; then
echo -e "\nSuccess: The 'sessions' folder has been copied to $target_dir."
else
echo -e "\nError: Failed to copy the 'sessions' folder to $target_dir."
fi
break
else
echo "Invalid selection. Please try again."
fi
done
fi
break
else
echo "Invalid selection. Please try again."
fi
done