-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-text-dirs
More file actions
executable file
·44 lines (36 loc) · 1.9 KB
/
create-text-dirs
File metadata and controls
executable file
·44 lines (36 loc) · 1.9 KB
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
#!/bin/bash
# This script accepts a dir path as an argument and then:
# 1. Creates 114 new directories in the specified directory named "1" through "114", corresponding to the 114 chapters in the Quran.
# 2. Inside each of the 114 directories, it creates directories named "1" through "n" where n is the number of verses in that chapter.
# 3. Inside each verse directory, it creates an empty file named index.txt.
# Check if the user has provided a directory path
if [ -z "$1" ]; then
echo "Please provide a directory path as an argument."
exit 1
fi
# Check if the provided path is a directory
if [ ! -d "$1" ]; then
echo "The provided path is not a directory."
exit 1
fi
# name the argument for easier reference
base_dir=$1
# array of the number of verses in each chapter
declare -a verses=(7 286 200 176 120 165 206 75 129 109 123 111 43 52 99 128 111 110 98 135 112 78 118 64 77 227 93 88 69 60 34 30 73 54 45 83 182 88 75 85 54 53 89 59 37 35 38 29 18 45 60 49 62 55 78 96 29 22 24 13 14 11 11 18 12 12 30 52 52 44 28 28 20 56 40 31 50 40 46 42 29 19 36 25 22 17 19 26 30 20 15 21 11 8 8 19 5 8 8 11 11 8 3 9 5 4 7 3 6 3 5 4 5 6)
# create 114 directories named "1" through "114"
for i in {1..114}; do
mkdir -p "$base_dir/$i"
# create directories named "1" through "n" where n is the number of verses in that chapter
for j in $(seq 1 ${verses[$i-1]}); do
mkdir -p "$base_dir/$i/$j"
# create an empty file named index.txt in each verse directory
touch "$base_dir/$i/$j/index.txt"
# if $base_dir ends with 'ar', then create a subdirectory named 'diacritized' in each verse directory
# and create an empty file named index.txt in the 'diacritized' directory
if [[ $base_dir == *ar ]]; then
mkdir -p "$base_dir/$i/$j/diacritized"
touch "$base_dir/$i/$j/diacritized/index.txt"
fi
done
done
echo "Directories created successfully."