generated from busycaesar/Repository_Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_dir_list
More file actions
executable file
·32 lines (26 loc) · 790 Bytes
/
process_dir_list
File metadata and controls
executable file
·32 lines (26 loc) · 790 Bytes
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
#!/bin/bash
# Check for required arguments
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <script_path> <dir_list_file>"
exit 1
fi
DIR_LIST_FILE="$2"
SCRIPT="$1"
# Check if the directory list file exists
if [ ! -f "$DIR_LIST_FILE" ]; then
echo "Directory list file not found: $DIR_LIST_FILE"
exit 1
fi
# Check if the commit script exists and is executable
if [ ! -x "$SCRIPT" ]; then
echo "Commit script not found or not executable: $SCRIPT"
exit 1
fi
# Loop through each line in the list
while IFS= read -r dir_path || [ -n "$dir_path" ]; do
# Skip empty lines or lines starting with #
[[ -z "$dir_path" || "$dir_path" =~ ^# ]] && continue
echo "Backing up: $dir_path"
"$SCRIPT" "$dir_path"
echo "---------------------------------"
done < "$DIR_LIST_FILE"