-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite_filepaths.sh
More file actions
31 lines (28 loc) · 923 Bytes
/
write_filepaths.sh
File metadata and controls
31 lines (28 loc) · 923 Bytes
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
#! /bin/bash
# Date: 2024/11/12
# Author: Mario Portocarrero
# Description:
# This script:
# 1. extracts pathnames from the subdirectories of `./image-collections`
# 2. writes those pathnames to `./image-viewer/filepaths.js`
#
# Usage:
# i. extract pathnames of image files from all subdirectories
# $ ./write_filepaths.sh
# store pathnames of image files in the pathnames variable
IMAGE_COLLECTIONS="image-collections"
pathnames=""
for image_dir in $(ls $IMAGE_COLLECTIONS)
do
for filename in $(ls "./$IMAGE_COLLECTIONS/$image_dir")
do
pathname="'../$IMAGE_COLLECTIONS/$image_dir/$filename'"
if [ "$pathnames" == "" ]; then
pathnames="\n$pathname"
else
pathnames="$pathnames,\n $pathname"
fi
done
done
printf "let filepaths = [$pathnames \n];" > "./image-viewer/filepaths.js"
# printf "\n\nlet imageDirs = '$(ls $IMAGE_COLLECTIONS | xargs)'" >> "./image-viewer/filepaths.js"