#!/bin/bash # mma - minion move to archive # Moves all matching files to $HOME/Journal/archive_YYYY/ year=`date +%Y` # File to gather all content into topic=$1 if [ ! -n "$1" ]; then echo "A topic to archive is required." exit 1 fi archive="$HOME/Journal/archive-$year/" files=$(find $HOME/Journal/$year -type f -iname "*$1*\.md") if [ -n "$files" ]; then echo "Will archive $files to $archive" else echo "Nothing to archive for $topic" fi echo "" read -n1 -p "Continue? [y,N]" input echo "" if [[ ! $input == "Y" && ! $input == "y" ]]; then echo "Aborted by user" exit 1 fi mkdir -p $archive mv $files $archive