Last active
April 5, 2020 19:26
-
-
Save jimkang/1c4c9e44fe4133c8c3159572858bf0e3 to your computer and use it in GitHub Desktop.
Simple script for getting markdown files in a certain date range (assuming the files use a common Zettelkasten naming convention in which every file starts with YYYY-MM-DD).
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 | |
src=. | |
start=$1 | |
end=$2 | |
if [[ ! $start ]] && [[ ! $end ]]; then | |
printf "Usage: ./tools/get-entries-in-date-range.sh [start string] [end string]\nEnd string is optional.\n\nExample: To get filenames that come after 2020-03 (anywhere in March) but before 2020-03-29 (assuming files follow this naming convention):\n./tools/get-entries-in-date-range.sh 2020-03 2020-03-29\n"; | |
exit 1; | |
fi | |
if [[ ! $end ]]; then | |
end=9999-99-99 | |
fi | |
for file in ${src}/*.md | |
do | |
filename="${file##*/}" | |
if [[ "$filename" > "$start" ]] && [[ "$filename" < "$end" ]]; then | |
echo "$filename" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment