Created
June 30, 2021 03:35
-
-
Save lee2sman/17bd6fa484c85c8952e7180f481386f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
## A hack to export all image files to a json list | |
# find name of last file in directory | |
declare -a files | |
files=(img/*) | |
pos=$(( ${#files[*]} - 1 )) | |
last=${files[$pos]} | |
#overwrite file if already there | |
echo "{" > img-list.json | |
echo ' "name": [' >> img-list.json | |
for FILE in "${files[@]}" | |
do | |
if [[ $FILE == $last ]] | |
then | |
echo " "\"$FILE\" >> img-list.json | |
break | |
else | |
echo " "\"$FILE\", >> img-list.json | |
fi | |
done | |
echo " ]" >> img-list.json | |
echo "}" >> img-list.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment