21 lines
538 B
Bash
Executable File
21 lines
538 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Find all .zim files in current directory and format them as an array
|
|
zim_files=()
|
|
while IFS= read -r -d $'\0' file; do
|
|
zim_files+=("\"$(basename "$file")\"")
|
|
done < <(find . -maxdepth 1 -type f -name "*.zim" -print0)
|
|
|
|
# Format the output
|
|
if [ ${#zim_files[@]} -gt 0 ]; then
|
|
printf "[\n"
|
|
printf " %s" "${zim_files[0]}"
|
|
for ((i=1; i<${#zim_files[@]}; i++)); do
|
|
printf ",\n %s" "${zim_files[$i]}"
|
|
done
|
|
printf "\n]\n"
|
|
else
|
|
echo "No .zim files found in current directory"
|
|
exit 1
|
|
fi
|