From 6e9ee4127716e974360d7bb2aea3cb4f22db658b Mon Sep 17 00:00:00 2001 From: simon987 Date: Sat, 19 Dec 2020 17:26:52 -0500 Subject: [PATCH] update to make it work with busybox --- podcast_share | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/podcast_share b/podcast_share index 2b41d3a..93fee24 100755 --- a/podcast_share +++ b/podcast_share @@ -1,11 +1,9 @@ #!/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) - - +DATE_RANGE="45" +IN="/main/staging/rss/" +OUT="/main/audio/shared" +TARGET_DATE=$(($(date +%s) - (3600*24*$DATE_RANGE))) rm /tmp/list.txt 2>/dev/null @@ -14,15 +12,15 @@ do fileName=$(basename "${file}") fileDate=$(echo $fileName | cut -c1-10) fileTime=$(date --date "${fileDate}" +%s) - relPath=$(realpath --relative-to="${IN}" "${file}") + relPath=$(realpath "${file}" | cut -c$((${#IN} + 1))-) + 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}" +rsync -aP --no-relative --files-from=/tmp/list.txt "${IN}" "${OUT}"