-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFont_File_Separatornator.sh
executable file
·64 lines (55 loc) · 2.1 KB
/
Font_File_Separatornator.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Font_File_Separatornator.sh
# Version: 1.0.0
# Author: John Choura
# License: This project is licensed under the MIT License (https://github.com/johnchourajr/font-file-separatornator/blob/main/LICENSE).
# ------------------------------------------------
# Instructions:
# cd to the path of the scipt
# chmod +x Font_File_Separatornator.sh
# ./Font_File_Separatornator.sh
# ------------------------------------------------
#!/bin/bash
# Your source directory is set to the current directory
SOURCE_DIR="$(pwd)"
# Destination directories for .ttf and .woff2 files, created as siblings to SOURCE_DIR
DEST_TTF_DIR="${SOURCE_DIR}/all TTFs"
DEST_WOFF2_DIR="${SOURCE_DIR}/all WOFF2s"
DEST_OTF_DIR="${SOURCE_DIR}/all OTFs"
echo "Source directory: $SOURCE_DIR"
echo "Destination TTF directory: $DEST_TTF_DIR"
echo "Destination WOFF2 directory: $DEST_WOFF2_DIR"
echo "Destination OTF directory: $DEST_OTF_DIR"
# Create the destination directories if they don't exist
if [[ ! -d "$DEST_TTF_DIR" ]]; then
mkdir "$DEST_TTF_DIR"
echo "Created directory: $DEST_TTF_DIR"
fi
if [[ ! -d "$DEST_WOFF2_DIR" ]]; then
mkdir "$DEST_WOFF2_DIR"
echo "Created directory: $DEST_WOFF2_DIR"
fi
if [[ ! -d "$DEST_OTF_DIR" ]]; then
mkdir "$DEST_OTF_DIR"
echo "Created directory: $DEST_OTF_DIR"
fi
# Copy all .ttf files to the 'all TTFs' directory
find "$SOURCE_DIR" -type f -name "*.ttf" | while read -r file; do
# Check if file is not already in the destination directory
if [[ "$file" != "${DEST_TTF_DIR}"/* ]]; then
cp "$file" "$DEST_TTF_DIR/"
fi
done
# Copy all .woff2 files to the 'all WOFF2s' directory
find "$SOURCE_DIR" -type f -name "*.woff2" | while read -r file; do
# Check if file is not already in the destination directory
if [[ "$file" != "${DEST_WOFF2_DIR}"/* ]]; then
cp "$file" "$DEST_WOFF2_DIR/"
fi
done
# Copy all .otf files to the 'all OTFs' directory
find "$SOURCE_DIR" -type f -name "*.otf" | while read -r file; do
# Check if file is not already in the destination directory
if [[ "$file" != "${DEST_OTF_DIR}"/* ]]; then
cp "$file" "$DEST_OTF_DIR/"
fi
done