Skip to content

Instantly share code, notes, and snippets.

@annalinneajohansson
Last active February 8, 2020 01:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save annalinneajohansson/5b67e5926bf6350a69cb08ec9793c905 to your computer and use it in GitHub Desktop.
Save annalinneajohansson/5b67e5926bf6350a69cb08ec9793c905 to your computer and use it in GitHub Desktop.
Iterate Jpg images in folder and add Dropbox share link to csv
#!/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