Skip to content

Instantly share code, notes, and snippets.

@sk22
Created July 18, 2020 15:50
Show Gist options
  • Save sk22/9f3ad919aecee2db4b87dceec0208864 to your computer and use it in GitHub Desktop.
Save sk22/9f3ad919aecee2db4b87dceec0208864 to your computer and use it in GitHub Desktop.
Creates photo album by linking files with a certain keyword in filename/path
#!/bin/sh
# expected file structure:
# 2018/
# 2019/
# ...
# albums/
# create-album-by-keyword.sh
# working directory must be /albums!
if [ -z "$1" ]; then
echo "Parameter expected"
exit 1
fi
folder="${2:-$1}"
echo keyword $1
echo folder $folder
mkdir $folder
# create hard links for each file (will also work with smb shares)
find ../ -path "*$1*" -type f -not -path "../albums/*" -exec ln {} ./$folder \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment