Last active
February 8, 2020 01:38
-
-
Save annalinneajohansson/5b67e5926bf6350a69cb08ec9793c905 to your computer and use it in GitHub Desktop.
Iterate Jpg images in folder and add Dropbox share link to csv
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
#!/bin/bash | |
rm -rf images.csv | |
for file in *; do | |
if [[ $file == *.jpg ]] | |
then | |
sharelink=$(dropbox sharelink "$file") | |
sharelink=${sharelink/dl=0/dl=1} ## replace dl=0 with dl=1 in the sharelinks | |
filename=$(basename "$file") | |
extension="${filename##*.}" | |
filename_no_ext="${filename%.*}" | |
filename_stripped="${filename_no_ext% *}" ## only keep chars up until first space | |
filename_stripped="${filename_stripped%_*}" ## only keep chars up until first downscore (_) | |
echo "$filename_stripped,$filename,$sharelink" >> images.csv | |
echo "Added $filename" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment