-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_missing_txt.sh
More file actions
executable file
·62 lines (50 loc) · 1.69 KB
/
create_missing_txt.sh
File metadata and controls
executable file
·62 lines (50 loc) · 1.69 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Script to check for .flac files and create corresponding .txt files if they don't exist
# Usage: ./create_missing_txt.sh
# Base directories
FLAC_DIR="./flac"
RAW_DIR="./raw"
# Create flac directory if it doesn't exist
if [ ! -d "$FLAC_DIR" ]; then
mkdir -p "$FLAC_DIR"
echo "Created flac directory: $FLAC_DIR"
fi
# Function to check and create txt files if they don't exist
check_and_create_txt_files() {
local flac_file="$1"
local relative_path="${flac_file#$FLAC_DIR/}"
local filename=$(basename "$relative_path" .flac)
local directory=$(dirname "$relative_path")
# Create the corresponding directory in raw if it doesn't exist
local raw_dir="$RAW_DIR/$directory"
# Check if the txt files exist, create them if they don't
local txt_file="$raw_dir/$filename.txt"
local prompt_txt_file="$raw_dir/${filename}_prompt.txt"
# Create directory if it doesn't exist
if [ ! -d "$raw_dir" ]; then
mkdir -p "$raw_dir"
echo "Created directory: $raw_dir"
fi
# Create .txt file if it doesn't exist
if [ ! -f "$txt_file" ]; then
touch "$txt_file"
echo "Created: $txt_file"
fi
# Create _prompt.txt file if it doesn't exist
if [ ! -f "$prompt_txt_file" ]; then
touch "$prompt_txt_file"
echo "Created: $prompt_txt_file"
fi
}
# Find all flac files and check for corresponding txt files
echo "Checking for missing txt files..."
count=0
find "$FLAC_DIR" -type f -name "*.flac" | while read flac_file; do
check_and_create_txt_files "$flac_file"
((count++))
done
if [ $count -eq 0 ]; then
echo "No flac files found."
else
echo "Processed $count flac files."
fi