File size: 754 Bytes
712958f |
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 |
#!/bin/bash
#
# Pull captions from filenames and make them suitable for use by Khoya trainer.
#
# Directory containing the .png files
png_directory="/path/to/png_files"
# Directory to save the .txt files
txt_directory="/path/to/txt_files"
# Create the txt_directory if it doesn't exist
mkdir -p "$txt_directory"
# Loop through each .png file in the png_directory
for png_file in "$png_directory"/*.png; do
# Extract the filename without the extension
base_name=$(basename "$png_file" .png)
# Replace underscores with spaces
txt_content="${base_name//_/ }"
# Create a .txt file with the same name and write the content
echo "$txt_content" > "$txt_directory/${base_name}.txt"
done
echo "TXT files created in $txt_directory"
|