From f6f2f5ed7cdba0fca10702fc6ee63e06b364aca2 Mon Sep 17 00:00:00 2001 From: simon987 Date: Sun, 29 Nov 2020 18:56:08 -0500 Subject: [PATCH] podcast --- podcast_share | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 podcast_share diff --git a/podcast_share b/podcast_share new file mode 100755 index 0000000..2b41d3a --- /dev/null +++ b/podcast_share @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +DATE_RANGE="45 days ago" +IN="/home/rutorrent/main/staging/rss" +OUT="/home/rutorrent/main/audio/shared" +TARGET_DATE=$(date --date "${DATE_RANGE}" +%s) + + + +rm /tmp/list.txt 2>/dev/null + +find "${IN}" -iname "*.mp3" -print0 | while read -d $'\0' file +do + fileName=$(basename "${file}") + fileDate=$(echo $fileName | cut -c1-10) + fileTime=$(date --date "${fileDate}" +%s) + relPath=$(realpath --relative-to="${IN}" "${file}") + + if [[ $TARGET_DATE -le $fileTime ]]; then + echo $relPath >> /tmp/list.txt + + else + rm "${OUT}/$relPath" 2>/dev/null + fi +done + + +rsync -aP --files-from=/tmp/list.txt "${IN}" "${OUT}"