From 04372c0b720429b4edc91c454c98b5957ce6ca72 Mon Sep 17 00:00:00 2001 From: Yudi Date: Wed, 18 Sep 2019 13:04:34 -0300 Subject: [PATCH] Improved script to be able to handle multiple export tasks at the same directory --- Scheduling-exports-with-Mono-&-Crontab.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Scheduling-exports-with-Mono-&-Crontab.md b/Scheduling-exports-with-Mono-&-Crontab.md index 111be0e..12b6ee4 100644 --- a/Scheduling-exports-with-Mono-&-Crontab.md +++ b/Scheduling-exports-with-Mono-&-Crontab.md @@ -20,6 +20,7 @@ FILENAME= EXPORTDIRECTORY= EXPORTFORMAT= # Available export formats: PlainText, HtmlDark, HtmlLight, Csv +# /\ CaSe-SeNsItIvE /\ cd $EXEPATH || exit 1 @@ -29,21 +30,23 @@ fi PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin -mono DiscordChatExporter.Cli.exe export -t $TOKEN $ISBOTYES -c $CHANNEL -f $EXPORTFORMAT -o export.tmp +mono DiscordChatExporter.Cli.exe export -t $TOKEN $ISBOTYES -c $CHANNEL -f $EXPORTFORMAT -o $FILENAME.tmp CURRENTTIME=$(date +"%Y-%m-%d-%H-%M-%S") if [[ "$EXPORTFORMAT" == "PlainText" ]]; then - mv "export.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.txt" + mv "$FILENAME.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.txt" -elif [[ "$EXPORTFORMAT" == "Html"* ]]; then - mv "export.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.html" +elif [[ "$EXPORTFORMAT" == "HtmlDark" ]] || [[ "$EXPORTFORMAT" == "HtmlLight" ]]; then + mv "$FILENAME.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.html" elif [[ "$EXPORTFORMAT" == "Csv" ]]; then - mv "export.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.csv" + mv "$FILENAME.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.csv" else echo "$EXPORTFORMAT - Unknown export format" -if ! rm -Rf "export.tmp" ; then -echo "Unable to delete $PWD/export.tmp" +echo "Available export formats: PlainText, HtmlDark, HtmlLight, Csv" +echo "/\ CaSe-SeNsItIvE /\\" +if ! rm -Rf "$FILENAME.tmp" ;then +echo "Unable to delete $PWD/$FILENAME.tmp" fi exit 1 fi